Spring diary

주가희·2023년 11월 23일

12/13
스케줄 검색 스케줄 One 이랑 연결 완료

12/14
notice 수정, 삭제 관리자만 되도록 수정
(쿼리수정 필요) jsp는 수정 함

notice삭제시 comment 삭제 후 삭제되도록 트랜젝션 처리 하기

모든 컨트롤러는 서비스를 거쳐가도록 수정

모든 Autowired private로 수정
쿼리로 비밀글 구현해보려고 한 쿼리 결국 jsp에서 구현

	<select id="selectComment" parameterType="int" resultType="java.util.Map">
		SELECT 
			comment_no commentNo,
			notice_no noticeNo,
			member_id memberId,
			is_secret isSecret
		FROM comment
		WHERE notice_no= #{noticeNo}
		AND
		     <!-- 전체 공개 -->
		<if test="isSecret == 0">
			comment_content commentContent
    	</if>
    		<!-- 비밀글 -->
	     <if test="isSecret == 1">
        <!-- memberLevel이 1이거나 member_id가 loginMemberId와 동일 -->
        <choose>
        	<!-- when 태크의 test 속성은 OGNL 표현식으로 표현 #{} 없어도 됨  -->
          	<when test="memberLevel == 1 or member_id == loginMemberId">
            <!-- 비밀글의 내용인 comment_content를 출력 -->
            	comment_content AS commentContent
          	</when>
          	<!-- 그 외의 경우, '비밀글입니다'를 출력 -->
          	<otherwise>
				'비밀글입니다' AS commentContent
          	</otherwise>
        </choose>
      </if>
	</select>
<c:choose>
    <!-- memberLevel이 1이거나 comment의 작성자가 현재 로그인한 사용자와 동일한 경우 -->
    <c:when test="${memberLevel == 1 or comment.memberId == loginMemberId}">
        <td colspan="5">
            <textarea rows="3" cols="50" name="commentContent" readonly="readonly">${comment.commentContent}</textarea>
        </td>
    </c:when>
    <!-- 그 외의 경우, '비밀글입니다'를 출력 -->
    <c:otherwise>
        <td colspan="5">
            <textarea rows="3" cols="50" name="commentContent" readonly="readonly">비밀글입니다</textarea>
        </td>
    </c:otherwise>
</c:choose>
			<c:if test="${memberLevel == 1 or comment.memberId == loginMemberId}  ">
				<td colspan="5"><textarea rows="3" cols="50" name="commentContent" readonly="readonly">${comment.commentContent}</textarea></td>
			</c:if>
			<c:if test="${memberLevel == 0 and comment.memberId != loginMemberId}  ">
				<td colspan="5"><textarea rows="3" cols="50" name="commentContent" readonly="readonly">비밀글입니다</textarea></td>
			</c:if>
profile
주웅

0개의 댓글