Skip to content

Commit

Permalink
Merge pull request #163 from ssu-student-union/feat/142-post
Browse files Browse the repository at this point in the history
[feat]: #142 공식댓글 수정 예외처리
  • Loading branch information
beakgugong authored Nov 30, 2024
2 parents 54bdbb8 + 96265a7 commit 646bada
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public enum ErrorStatus implements BaseErrorCode {

//PostComment 관련 에러
POST_COMMENT_NOT_FOUND(HttpStatus.NOT_FOUND,"POST_COMMENT_001","댓글을 찾을 수 없습니다."),
POST_COMMENT_NOT_DELETE(HttpStatus.NOT_FOUND, "POST_COMMENT_002", "공식댓글은 삭제할 수 없습니다."),

//PostReplyComment 관련 에러
POST_REPLY_COMMENT_NOT_FOUND(HttpStatus.NOT_FOUND,"POST_REPLY_COMMENT_001","대댓글을 찾을 수 없습니다."),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import org.springframework.stereotype.Repository;
import ussum.homepage.domain.comment.PostComment;
import ussum.homepage.domain.comment.PostCommentRepository;
import ussum.homepage.domain.reaction.exception.PostCommentException;
import ussum.homepage.domain.reaction.service.PostCommentReactionReader;
import ussum.homepage.infra.jpa.comment.entity.CommentType;
import ussum.homepage.infra.jpa.comment.entity.PostCommentEntity;
Expand All @@ -15,6 +16,7 @@
import java.util.List;
import java.util.Optional;

import static ussum.homepage.global.error.status.ErrorStatus.POST_COMMENT_NOT_DELETE;
import static ussum.homepage.infra.jpa.comment.entity.CommentType.GENERAL;
import static ussum.homepage.infra.jpa.comment.entity.PostCommentEntity.updateDeletedAt;
import static ussum.homepage.infra.jpa.comment.entity.QPostCommentEntity.postCommentEntity;
Expand Down Expand Up @@ -96,6 +98,9 @@ public PostComment update(PostComment postComment){

@Override
public void delete(PostComment postComment){
if (CommentType.getEnumCommentTypeFromStringCommentType(postComment.getCommentType()).equals(CommentType.OFFICIAL)){
throw new PostCommentException(POST_COMMENT_NOT_DELETE);
}
PostCommentEntity postCommentEntity = postCommentMapper.toEntity(postComment);
updateDeletedAt(postCommentEntity);
postCommentJpaRepository.save(postCommentEntity);
Expand Down

0 comments on commit 646bada

Please sign in to comment.