Notice
Recent Posts
Recent Comments
Link
«   2024/07   »
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31
Archives
Today
Total
관리 메뉴

KSI일기장

0509spring 게시물 댓글(3) 댓글 수정 및 삭제 본문

Spring

0509spring 게시물 댓글(3) 댓글 수정 및 삭제

MyDiaryYo 2023. 5. 11. 18:10

*댓글수정*

 

-ReplyController

//댓글 수정
	/*url : contextPath + "/reply/update",
    data : {"replyNo" : replyNo,
            "replyContent" : replyContent},
    type : "POST"
	 */
	@PostMapping("/update")
	public int replyUpdate(@ModelAttribute Reply reply ) {
		//				 -> vo객체를 가져올때는 @ModelAttribute 

		reply.getReplyNo();
		reply.getReplyContent();

		int result = replyservice.replyUpdate(reply);
		return result;
	}

 

-ReplyService

/**댓글수정
	 * @param
	 * @param replyNo
	 * @return
	 */
	int replyUpdate(Reply reply);

 

-ReplyServiceImpl

//댓글수정
	@Override
	public int replyUpdate(Reply reply) {
		return dao.replyUpdate(reply);
	}

 

-ReplyDAO

/**댓글수정
	 * @param replyNo
	 * @return
	 */
	public int replyUpdate(Reply reply) {
		return sqlSession.update("replyMapper.replyUpdate", reply);
	}

 

-reply-mapper.xml

<!-- 댓글수정 -->
	<update id="replyUpdate">
		UPDATE REPLY_S SET REPLY_CONTENT = #{replyContent}
		WHERE REPLY_NO = ${replyNo}
	</update>

 

*댓글삭제*

 

-ReplyController

//댓글 삭제
	/* url : contextPath + "/reply/delete",
    data : {"replyNo" : replyNo},
    type : "GET"
	*/
	@GetMapping("/delete")
	public int replyDelete(int replyNo) {
	
	int result = replyservice.replyDelete(replyNo);
	return result;
	
	}

 

-ReplyService

/**댓글삭제
	 * @param replyNo
	 * @return
	 */
	int replyDelete(int replyNo);

 

-ReplyServiceImpl

//댓글삭제
	@Override
	public int replyDelete(int replyNo) {
		return dao.replyDelete(replyNo);
	}

 

-ReplyDAO

/**댓글삭제
	 * @param replyNo
	 * @return
	 */
	public int replyDelete(int replyNo) {
		return sqlSession.update("replyMapper.replyDelete", replyNo);
	}

 

-reply-mapper.xml

<!-- 댓글삭제 -->
	<update id="replyDelete">
		UPDATE REPLY_S SET REPLY_ST = 'Y'
		WHERE REPLY_NO = #{replyNo}
	</update>