게시판 삭제 수정

This commit is contained in:
dyhj625 2025-03-27 10:55:57 +09:00
parent 01f936a407
commit 92119be6fa
3 changed files with 22 additions and 13 deletions

View File

@ -128,6 +128,8 @@ public interface localbordMapper {
int deleteTrashFileData(FileVo vo);
void deleteGoodOrBadByCommentId(MapDto map);
}

View File

@ -266,21 +266,22 @@ public class localbordService {
// 대댓글이 없는 경우, 완전 삭제
boardMapper.deleteComment(commentId);
}
// checkAndDeleteParentComment(map);
checkAndDeleteParentComment(map);
boardMapper.deleteGoodOrBadByCommentId(map);
}
// private void checkAndDeleteParentComment(MapDto map) {
// Long parentId = (Long) map.get("LOCCMTPNT");
// if (parentId == null) return; // 부모가 없으면 종료
//
// // 부모 댓글의 남아있는 대댓글 개수 확인
// int remainingReplies = boardMapper.selectReplyCount(parentId);
//
// if (remainingReplies == 0) {
// // 남은 대댓글이 없으면 부모 댓글도 삭제
// boardMapper.deleteComment(parentId);
// }
// }
private void checkAndDeleteParentComment(MapDto map) {
Long parentId = (Long) map.get("LOCCMTPNT");
if (parentId == null) return; // 부모가 없으면 종료
// 부모 댓글의 남아있는 대댓글 개수 확인
int remainingReplies = boardMapper.selectReplyCount(parentId);
if (remainingReplies == 0) {
// 남은 대댓글이 없으면 부모 댓글도 삭제
boardMapper.deleteComment(parentId);
}
}
public String selectCommentPassword(int commentId) {
return boardMapper.selectCommentPassword(commentId);

View File

@ -201,6 +201,12 @@
WHERE LOCBRDSEQ = #{LOCBRDSEQ}
</delete>
<!-- 댓글 및 대댓글 삭제 시 좋아요/싫어요 삭제 -->
<delete id="deleteGoodOrBadByCommentId">
DELETE FROM localgorb
WHERE LOCCMTSEQ = #{LOCCMTSEQ}
</delete>
<!-- 게시물 수정 -->
<update id="updateBoard">
UPDATE localbord