Skip to content

Commit a140d39

Browse files
committed
CLAP-332 HotFix: 댓글 삭제 버그 수정
1 parent 7e88b4f commit a140d39

File tree

3 files changed

+6
-9
lines changed

3 files changed

+6
-9
lines changed

src/main/java/clap/server/adapter/outbound/persistense/entity/task/CommentEntity.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
@Getter
1818
@SuperBuilder
1919
@NoArgsConstructor(access = AccessLevel.PROTECTED)
20-
@SQLDelete(sql = "UPDATE comment SET is_deleted = true WHERE comment_id = ?")
2120
@SQLRestriction("is_deleted = false")
2221
public class CommentEntity extends BaseTimeEntity {
2322
@Id

src/main/java/clap/server/adapter/outbound/persistense/repository/history/TaskHistoryRepository.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
@Repository
1111
public interface TaskHistoryRepository extends JpaRepository<TaskHistoryEntity, Long>, TaskHistoryCustomRepository {
12-
@Modifying
12+
@Modifying(clearAutomatically = true, flushAutomatically = true)
1313
@Query("UPDATE TaskHistoryEntity t SET t.isDeleted = true WHERE t.comment.commentId = :commentId")
1414
void updateByComment_CommentId(@Param("commentId") Long commentId);
1515
}

src/main/java/clap/server/application/service/history/CommandCommentService.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,16 +55,14 @@ public void deleteComment(Long userId, Long commentId) {
5555
Member member = memberService.findActiveMember(userId);
5656
Comment comment = commentService.findById(commentId);
5757

58-
if (Member.checkCommenter(comment.getTask(), member)) {
59-
// 첨부파일이 있을 경우 삭제
58+
59+
if (Objects.equals(comment.getMember().getMemberId(), member.getMemberId())) {
6060
if (loadAttachmentPort.exitsByCommentId(commentId)) {
6161
deleteAttachments(commentId);
6262
}
63-
// comment 삭제
64-
commandCommentPort.deleteComment(comment);
65-
// comment와 관련된 taskHistory도 함께 삭제
66-
67-
commandTaskHistoryPort.deleteTaskHistoryByCommentId(commentId);
63+
commandCommentPort.deleteCommentWithTaskHistory(commentId);
64+
}else{
65+
throw new DomainException(MemberErrorCode.NOT_A_COMMENTER);
6866
}
6967
}
7068

0 commit comments

Comments
 (0)