1818import clap .server .exception .DomainException ;
1919import clap .server .exception .code .CommentErrorCode ;
2020import clap .server .exception .code .MemberErrorCode ;
21+ import clap .server .exception .code .TaskErrorCode ;
2122import lombok .RequiredArgsConstructor ;
2223import lombok .extern .slf4j .Slf4j ;
2324import org .springframework .transaction .annotation .Transactional ;
@@ -35,34 +36,34 @@ public class CommandCommentService implements EditCommentUsecase, DeleteCommentU
3536 private final CommandCommentPort commandCommentPort ;
3637 private final LoadAttachmentPort loadAttachmentPort ;
3738 private final CommandAttachmentPort commandAttachmentPort ;
38- private final CommandTaskHistoryPort commandTaskHistoryPort ;
3939
4040 @ Transactional
4141 @ Override
42- public void editComment (Long userId , Long commentId , EditCommentRequest request ) {
43- Member member = memberService .findActiveMember (userId );
42+ public void editComment (Long memberId , Long commentId , EditCommentRequest request ) {
43+ Member member = memberService .findActiveMember (memberId );
4444 Comment comment = commentService .findById (commentId );
4545
46- if (Member . checkCommenter ( comment . getTask (), member )) {
46+ if (comment . getMember (). getMemberId (). equals ( member . getMemberId () )) {
4747 comment .updateComment (request .content ());
4848 commandCommentPort .saveComment (comment );
49- };
49+ }
50+ else throw new ApplicationException (CommentErrorCode .NOT_A_COMMENT_WRITER );
51+
5052 }
5153
5254 @ Transactional
5355 @ Override
54- public void deleteComment (Long userId , Long commentId ) {
55- Member member = memberService .findActiveMember (userId );
56+ public void deleteComment (Long memberId , Long commentId ) {
57+ Member member = memberService .findActiveMember (memberId );
5658 Comment comment = commentService .findById (commentId );
57-
58-
59- if (Objects .equals (comment .getMember ().getMemberId (), member .getMemberId ())) {
59+
60+ if (comment .getMember ().getMemberId ().equals (member .getMemberId ())) {
6061 if (loadAttachmentPort .exitsByCommentId (commentId )) {
6162 deleteAttachments (commentId );
6263 }
6364 commandCommentPort .deleteCommentWithTaskHistory (commentId );
6465 }else {
65- throw new DomainException ( MemberErrorCode . NOT_A_COMMENTER );
66+ throw new ApplicationException ( CommentErrorCode . NOT_A_COMMENT_WRITER );
6667 }
6768 }
6869
0 commit comments