From c3654845c40daecbccbbc1f443758170273fb764 Mon Sep 17 00:00:00 2001 From: donghyukseo Date: Mon, 18 Aug 2025 15:34:10 +0900 Subject: [PATCH 1/4] =?UTF-8?q?refactor=20:=20PostErrorCode=20=EC=83=9D?= =?UTF-8?q?=EC=84=B1=20=EB=B0=8F=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../command/CommentCommandServiceImpl.java | 3 ++- .../domain/post/code/PostErrorCode.java | 17 +++++++++++++++++ .../service/command/PostCommandServiceImpl.java | 13 +++++++------ .../service/query/PostQueryServiceImpl.java | 3 ++- 4 files changed, 28 insertions(+), 8 deletions(-) create mode 100644 src/main/java/naughty/tuzamate/domain/post/code/PostErrorCode.java diff --git a/src/main/java/naughty/tuzamate/domain/comment/service/command/CommentCommandServiceImpl.java b/src/main/java/naughty/tuzamate/domain/comment/service/command/CommentCommandServiceImpl.java index 0c91f3b..a58cca0 100644 --- a/src/main/java/naughty/tuzamate/domain/comment/service/command/CommentCommandServiceImpl.java +++ b/src/main/java/naughty/tuzamate/domain/comment/service/command/CommentCommandServiceImpl.java @@ -10,6 +10,7 @@ import naughty.tuzamate.domain.comment.service.FCMService; import naughty.tuzamate.domain.notification.entity.Notification; import naughty.tuzamate.domain.notification.service.NotificationService; +import naughty.tuzamate.domain.post.code.PostErrorCode; import naughty.tuzamate.domain.post.entity.Post; import naughty.tuzamate.domain.post.repository.PostRepository; import naughty.tuzamate.domain.user.entity.User; @@ -38,7 +39,7 @@ public CommentResDTO.CreateCommentResponseDTO createComment( .orElseThrow(() -> new CustomException(GeneralErrorCode.NOT_FOUND_404)); Post post = postRepository.findById(postId) - .orElseThrow(() -> new CustomException(GeneralErrorCode.NOT_FOUND_404)); + .orElseThrow(() -> new CustomException(PostErrorCode.POST_NOT_FOUND)); Comment parent = null; diff --git a/src/main/java/naughty/tuzamate/domain/post/code/PostErrorCode.java b/src/main/java/naughty/tuzamate/domain/post/code/PostErrorCode.java new file mode 100644 index 0000000..5ba2e48 --- /dev/null +++ b/src/main/java/naughty/tuzamate/domain/post/code/PostErrorCode.java @@ -0,0 +1,17 @@ +package naughty.tuzamate.domain.post.code; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import naughty.tuzamate.global.error.BaseErrorCode; +import org.springframework.http.HttpStatus; + +@AllArgsConstructor +@Getter +public enum PostErrorCode implements BaseErrorCode { + + POST_NOT_FOUND(HttpStatus.NOT_FOUND, "POST404", "게시글이 존재하지 않습니다."),; + + private final HttpStatus status; + private final String code; + private final String message; +} diff --git a/src/main/java/naughty/tuzamate/domain/post/service/command/PostCommandServiceImpl.java b/src/main/java/naughty/tuzamate/domain/post/service/command/PostCommandServiceImpl.java index 6fcd128..c2ed55f 100644 --- a/src/main/java/naughty/tuzamate/domain/post/service/command/PostCommandServiceImpl.java +++ b/src/main/java/naughty/tuzamate/domain/post/service/command/PostCommandServiceImpl.java @@ -2,6 +2,7 @@ import lombok.RequiredArgsConstructor; import naughty.tuzamate.auth.principal.PrincipalDetails; +import naughty.tuzamate.domain.post.code.PostErrorCode; import naughty.tuzamate.domain.post.converter.PostConverter; import naughty.tuzamate.domain.post.dto.PostReqDTO; import naughty.tuzamate.domain.post.dto.PostResDTO; @@ -46,7 +47,7 @@ public PostResDTO.UpdatePostResponseDTO updatePost( ) { // reqDTO -> Post Entity, Post Entity -> resDTO Post post = postRepository.findById(postId) - .orElseThrow(() -> new CustomException(GeneralErrorCode.NOT_FOUND_404)); + .orElseThrow(() -> new CustomException(PostErrorCode.POST_NOT_FOUND)); if (!post.getUser().getId().equals(principalDetails.getUser().getId())) { throw new CustomException(GeneralErrorCode.FORBIDDEN_403); // 권한 없음 @@ -65,7 +66,7 @@ public PostResDTO.UpdatePostResponseDTO updatePost( @Override public PostResDTO.DeletePostResponseDTO deletePost(Long postId, PrincipalDetails principalDetails) { Post post = postRepository.findById(postId) - .orElseThrow(() -> new CustomException(GeneralErrorCode.NOT_FOUND_404)); + .orElseThrow(() -> new CustomException(PostErrorCode.POST_NOT_FOUND)); if (!post.getUser().getId().equals(principalDetails.getUser().getId())) { throw new CustomException(GeneralErrorCode.FORBIDDEN_403); // 권한 없음 @@ -79,7 +80,7 @@ public PostResDTO.DeletePostResponseDTO deletePost(Long postId, PrincipalDetails @Override public String postLike(Long postId, PrincipalDetails principalDetails) { Post post = postRepository.findById(postId) - .orElseThrow(() -> new CustomException(GeneralErrorCode.NOT_FOUND_404)); + .orElseThrow(() -> new CustomException(PostErrorCode.POST_NOT_FOUND)); User user = userRepository.findById(principalDetails.getId()) .orElseThrow(() -> new CustomException(GeneralErrorCode.NOT_FOUND_404)); @@ -102,7 +103,7 @@ public String postLike(Long postId, PrincipalDetails principalDetails) { @Override public String deleteLike(Long postId, PrincipalDetails principalDetails) { Post post = postRepository.findById(postId) - .orElseThrow(() -> new CustomException(GeneralErrorCode.NOT_FOUND_404)); + .orElseThrow(() -> new CustomException(PostErrorCode.POST_NOT_FOUND)); User user = userRepository.findById(principalDetails.getId()) .orElseThrow(() -> new CustomException(GeneralErrorCode.NOT_FOUND_404)); @@ -117,7 +118,7 @@ public String deleteLike(Long postId, PrincipalDetails principalDetails) { @Override public String postScrap(Long postId, PrincipalDetails principalDetails) { Post post = postRepository.findById(postId) - .orElseThrow(() -> new CustomException(GeneralErrorCode.NOT_FOUND_404)); + .orElseThrow(() -> new CustomException(PostErrorCode.POST_NOT_FOUND)); User user = userRepository.findById(principalDetails.getId()) .orElseThrow(() -> new CustomException(GeneralErrorCode.NOT_FOUND_404)); @@ -134,7 +135,7 @@ public String postScrap(Long postId, PrincipalDetails principalDetails) { @Override public String deleteScrap(Long postId, PrincipalDetails principalDetails) { Post post = postRepository.findById(postId) - .orElseThrow(() -> new CustomException(GeneralErrorCode.NOT_FOUND_404)); + .orElseThrow(() -> new CustomException(PostErrorCode.POST_NOT_FOUND)); User user = userRepository.findById(principalDetails.getId()) .orElseThrow(() -> new CustomException(GeneralErrorCode.NOT_FOUND_404)); diff --git a/src/main/java/naughty/tuzamate/domain/post/service/query/PostQueryServiceImpl.java b/src/main/java/naughty/tuzamate/domain/post/service/query/PostQueryServiceImpl.java index 57f6979..0a3383f 100644 --- a/src/main/java/naughty/tuzamate/domain/post/service/query/PostQueryServiceImpl.java +++ b/src/main/java/naughty/tuzamate/domain/post/service/query/PostQueryServiceImpl.java @@ -2,6 +2,7 @@ import lombok.RequiredArgsConstructor; import naughty.tuzamate.auth.principal.PrincipalDetails; +import naughty.tuzamate.domain.post.code.PostErrorCode; import naughty.tuzamate.domain.post.converter.PostConverter; import naughty.tuzamate.domain.post.dto.PostResDTO; import naughty.tuzamate.domain.post.entity.Post; @@ -33,7 +34,7 @@ public class PostQueryServiceImpl implements PostQueryService { @Override public PostResDTO.PostDTO getPost(Long postId, PrincipalDetails principalDetails) { Post post = postRepository.findById(postId) - .orElseThrow(() -> new CustomException(GeneralErrorCode.NOT_FOUND_404)); + .orElseThrow(() -> new CustomException(PostErrorCode.POST_NOT_FOUND)); if (!post.isRead()) { post.setIsRead(); From 820e18dd7dfbf1744bf0c705d39d10da1e2b6321 Mon Sep 17 00:00:00 2001 From: donghyukseo Date: Mon, 18 Aug 2025 15:39:13 +0900 Subject: [PATCH 2/4] =?UTF-8?q?refactor=20:=20CommentErrorCode=20=EC=83=9D?= =?UTF-8?q?=EC=84=B1=20=EB=B0=8F=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/comment/code/CommentErrorCode.java | 17 +++++++++++++++++ .../command/CommentCommandServiceImpl.java | 9 +++++---- .../service/query/CommentQueryServiceImpl.java | 3 ++- 3 files changed, 24 insertions(+), 5 deletions(-) create mode 100644 src/main/java/naughty/tuzamate/domain/comment/code/CommentErrorCode.java diff --git a/src/main/java/naughty/tuzamate/domain/comment/code/CommentErrorCode.java b/src/main/java/naughty/tuzamate/domain/comment/code/CommentErrorCode.java new file mode 100644 index 0000000..c4d4178 --- /dev/null +++ b/src/main/java/naughty/tuzamate/domain/comment/code/CommentErrorCode.java @@ -0,0 +1,17 @@ +package naughty.tuzamate.domain.comment.code; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import naughty.tuzamate.global.error.BaseErrorCode; +import org.springframework.http.HttpStatus; + +@AllArgsConstructor +@Getter +public enum CommentErrorCode implements BaseErrorCode { + + COMMENT_NOT_FOUND(HttpStatus.NOT_FOUND, "COMMENT404", "댓글이 존재하지 않습니다."),; + + private final HttpStatus status; + private final String code; + private final String message; +} diff --git a/src/main/java/naughty/tuzamate/domain/comment/service/command/CommentCommandServiceImpl.java b/src/main/java/naughty/tuzamate/domain/comment/service/command/CommentCommandServiceImpl.java index a58cca0..77dfba0 100644 --- a/src/main/java/naughty/tuzamate/domain/comment/service/command/CommentCommandServiceImpl.java +++ b/src/main/java/naughty/tuzamate/domain/comment/service/command/CommentCommandServiceImpl.java @@ -2,6 +2,7 @@ import lombok.RequiredArgsConstructor; import naughty.tuzamate.auth.principal.PrincipalDetails; +import naughty.tuzamate.domain.comment.code.CommentErrorCode; import naughty.tuzamate.domain.comment.converter.CommentConverter; import naughty.tuzamate.domain.comment.dto.CommentReqDTO; import naughty.tuzamate.domain.comment.dto.CommentResDTO; @@ -36,7 +37,7 @@ public CommentResDTO.CreateCommentResponseDTO createComment( CommentReqDTO.CreateCommentRequestDTO reqDTO, Long postId, PrincipalDetails principalDetails ) { User commentWriter = userRepository.findById(principalDetails.getId()) - .orElseThrow(() -> new CustomException(GeneralErrorCode.NOT_FOUND_404)); + .orElseThrow(() -> new CustomException(CommentErrorCode.COMMENT_NOT_FOUND)); Post post = postRepository.findById(postId) .orElseThrow(() -> new CustomException(PostErrorCode.POST_NOT_FOUND)); @@ -45,7 +46,7 @@ public CommentResDTO.CreateCommentResponseDTO createComment( if (reqDTO.parentId() != null) { parent = commentRepository.findById(reqDTO.parentId()) - .orElseThrow(() -> new CustomException(GeneralErrorCode.NOT_FOUND_404)); + .orElseThrow(() -> new CustomException(CommentErrorCode.COMMENT_NOT_FOUND)); } Comment comment = CommentConverter.toComment(reqDTO, commentWriter, post, parent); @@ -100,7 +101,7 @@ public CommentResDTO.UpdateCommentResponseDTO updateComment( PrincipalDetails principalDetails ) { Comment comment = commentRepository.findById(commentId) - .orElseThrow(() -> new CustomException(GeneralErrorCode.NOT_FOUND_404)); + .orElseThrow(() -> new CustomException(CommentErrorCode.COMMENT_NOT_FOUND)); if (!comment.getUser().getId().equals(principalDetails.getUser().getId())) { throw new CustomException(GeneralErrorCode.FORBIDDEN_403); // 권한 없음 @@ -114,7 +115,7 @@ public CommentResDTO.UpdateCommentResponseDTO updateComment( @Override public CommentResDTO.DeleteCommentResponseDTO deleteComment(Long commentId, PrincipalDetails principalDetails) { Comment comment = commentRepository.findById(commentId) - .orElseThrow(() -> new CustomException(GeneralErrorCode.NOT_FOUND_404)); + .orElseThrow(() -> new CustomException(CommentErrorCode.COMMENT_NOT_FOUND)); if (!comment.getUser().getId().equals(principalDetails.getUser().getId())) { throw new CustomException(GeneralErrorCode.FORBIDDEN_403); diff --git a/src/main/java/naughty/tuzamate/domain/comment/service/query/CommentQueryServiceImpl.java b/src/main/java/naughty/tuzamate/domain/comment/service/query/CommentQueryServiceImpl.java index 2708ccb..6d65a44 100644 --- a/src/main/java/naughty/tuzamate/domain/comment/service/query/CommentQueryServiceImpl.java +++ b/src/main/java/naughty/tuzamate/domain/comment/service/query/CommentQueryServiceImpl.java @@ -1,6 +1,7 @@ package naughty.tuzamate.domain.comment.service.query; import lombok.RequiredArgsConstructor; +import naughty.tuzamate.domain.comment.code.CommentErrorCode; import naughty.tuzamate.domain.comment.converter.CommentConverter; import naughty.tuzamate.domain.comment.dto.CommentResDTO; import naughty.tuzamate.domain.comment.entity.Comment; @@ -27,7 +28,7 @@ public class CommentQueryServiceImpl implements CommentQueryService { @Override public CommentResDTO.CommentPreviewDTO getComment(Long commentId) { Comment comment = commentRepository.findById(commentId) - .orElseThrow(() -> new CustomException(GeneralErrorCode.NOT_FOUND_404)); + .orElseThrow(() -> new CustomException(CommentErrorCode.COMMENT_NOT_FOUND)); return CommentConverter.toCommentPreviewDTO(comment, List.of()); } From 70f491073b6e8a9f461a40f0c046ad757bd518cf Mon Sep 17 00:00:00 2001 From: donghyukseo Date: Tue, 19 Aug 2025 23:10:13 +0900 Subject: [PATCH 3/4] =?UTF-8?q?feat=20:=20error=20=EC=BD=94=EB=93=9C=20?= =?UTF-8?q?=EB=B0=8F=20success=20=EC=BD=94=EB=93=9C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../code/NotificationErrorCode.java | 17 +++++++++++++++ .../service/NotificationService.java | 7 ++++--- .../domain/post/code/PostSuccessCode.java | 21 +++++++++++++++++++ .../post/controller/PostController.java | 7 ++++--- 4 files changed, 46 insertions(+), 6 deletions(-) create mode 100644 src/main/java/naughty/tuzamate/domain/notification/code/NotificationErrorCode.java create mode 100644 src/main/java/naughty/tuzamate/domain/post/code/PostSuccessCode.java diff --git a/src/main/java/naughty/tuzamate/domain/notification/code/NotificationErrorCode.java b/src/main/java/naughty/tuzamate/domain/notification/code/NotificationErrorCode.java new file mode 100644 index 0000000..baedca1 --- /dev/null +++ b/src/main/java/naughty/tuzamate/domain/notification/code/NotificationErrorCode.java @@ -0,0 +1,17 @@ +package naughty.tuzamate.domain.notification.code; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import naughty.tuzamate.global.error.BaseErrorCode; +import org.springframework.http.HttpStatus; + +@AllArgsConstructor +@Getter +public enum NotificationErrorCode implements BaseErrorCode { + + NOTIFICATION_NOT_FOUND(HttpStatus.NOT_FOUND, "NOTIFICATIONT404", "알림이 존재하지 않습니다."),; + + private final HttpStatus status; + private final String code; + private final String message; +} \ No newline at end of file diff --git a/src/main/java/naughty/tuzamate/domain/notification/service/NotificationService.java b/src/main/java/naughty/tuzamate/domain/notification/service/NotificationService.java index 36f4744..5cd3570 100644 --- a/src/main/java/naughty/tuzamate/domain/notification/service/NotificationService.java +++ b/src/main/java/naughty/tuzamate/domain/notification/service/NotificationService.java @@ -1,6 +1,7 @@ package naughty.tuzamate.domain.notification.service; import lombok.RequiredArgsConstructor; +import naughty.tuzamate.domain.notification.code.NotificationErrorCode; import naughty.tuzamate.domain.notification.converter.NotificationConverter; import naughty.tuzamate.domain.notification.dto.NotificationResDTO; import naughty.tuzamate.domain.notification.entity.Notification; @@ -58,7 +59,7 @@ public NotificationResDTO.NotificationCursorResDTO getNotificationList(Long user // 단일 알림 조회(이미 읽은 알림을 다시 읽는 경우) public NotificationResDTO.toNotificationResDTO getNotification(Long notificationId, Long userId) { Notification notification = notificationRepository.findByIdAndReceiverId(notificationId, userId) - .orElseThrow(() -> new CustomException(GeneralErrorCode.NOT_FOUND_404)); + .orElseThrow(() -> new CustomException(NotificationErrorCode.NOTIFICATION_NOT_FOUND)); return NotificationConverter.toNotificationDTO(notification); } @@ -67,7 +68,7 @@ public NotificationResDTO.toNotificationResDTO getNotification(Long notification @Transactional public NotificationResDTO.toNotificationResDTO updateIsRead(Long notificationId, Long userId) { Notification notification = notificationRepository.findByIdAndReceiverId(notificationId, userId) - .orElseThrow(() -> new CustomException(GeneralErrorCode.NOT_FOUND_404)); + .orElseThrow(() -> new CustomException(NotificationErrorCode.NOTIFICATION_NOT_FOUND)); notification.updateIsRead(); @@ -77,7 +78,7 @@ public NotificationResDTO.toNotificationResDTO updateIsRead(Long notificationId, @Transactional public void deleteNotification(Long notificationId, Long userId) { Notification notification = notificationRepository.findByIdAndReceiverId(notificationId, userId) - .orElseThrow(() -> new CustomException(GeneralErrorCode.NOT_FOUND_404)); + .orElseThrow(() -> new CustomException(NotificationErrorCode.NOTIFICATION_NOT_FOUND)); notificationRepository.delete(notification); } diff --git a/src/main/java/naughty/tuzamate/domain/post/code/PostSuccessCode.java b/src/main/java/naughty/tuzamate/domain/post/code/PostSuccessCode.java new file mode 100644 index 0000000..6c6d200 --- /dev/null +++ b/src/main/java/naughty/tuzamate/domain/post/code/PostSuccessCode.java @@ -0,0 +1,21 @@ +package naughty.tuzamate.domain.post.code; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import naughty.tuzamate.global.success.BaseSuccessCode; +import org.springframework.http.HttpStatus; + +@AllArgsConstructor +@Getter +public enum PostSuccessCode implements BaseSuccessCode { + + POST_OK(HttpStatus.OK, "200", "게시글 조회에 성공했습니다."), + + POST_CREATED(HttpStatus.CREATED, "201", "게시글이 생성되었습니다."), + + DELETED(HttpStatus.NO_CONTENT, "204", "성공적으로 삭제되었습니다."); + + private final HttpStatus status; + private final String code; + private final String message; +} diff --git a/src/main/java/naughty/tuzamate/domain/post/controller/PostController.java b/src/main/java/naughty/tuzamate/domain/post/controller/PostController.java index 402399c..7e25517 100644 --- a/src/main/java/naughty/tuzamate/domain/post/controller/PostController.java +++ b/src/main/java/naughty/tuzamate/domain/post/controller/PostController.java @@ -5,6 +5,7 @@ import jakarta.validation.constraints.Max; import lombok.RequiredArgsConstructor; import naughty.tuzamate.auth.principal.PrincipalDetails; +import naughty.tuzamate.domain.post.code.PostSuccessCode; import naughty.tuzamate.domain.post.dto.PostReqDTO; import naughty.tuzamate.domain.post.dto.PostResDTO; import naughty.tuzamate.domain.post.entity.Post; @@ -33,7 +34,7 @@ public CustomResponse createPost( ) { PostResDTO.CreatePostResponseDTO resDTO = postCommandService.createPost(boardType, reqDTO, principalDetails); - return CustomResponse.onSuccess(GeneralSuccessCode.CREATED, resDTO); + return CustomResponse.onSuccess(PostSuccessCode.POST_CREATED, resDTO); } @GetMapping("/boards/{boardType}/posts/{postId}") @@ -44,7 +45,7 @@ public CustomResponse getPost( ) { PostResDTO.PostDTO resDTO = postQueryService.getPost(postId, principalDetails); - return CustomResponse.onSuccess(GeneralSuccessCode.OK, resDTO); + return CustomResponse.onSuccess(PostSuccessCode.POST_OK, resDTO); } @GetMapping("/boards/{boardType}/posts") @@ -55,7 +56,7 @@ public CustomResponse getPostList( @RequestParam(defaultValue = "10") @Max(10) int size) { PostResDTO.PostPreviewListDTO resDTO = postQueryService.getPostList(boardType, cursor, size); - return CustomResponse.onSuccess(GeneralSuccessCode.OK, resDTO); + return CustomResponse.onSuccess(PostSuccessCode.POST_OK, resDTO); } @PatchMapping("/boards/{boardType}/posts/{postId}") From 32e5d8af5ca36333d9b025713eed7e404a30f23d Mon Sep 17 00:00:00 2001 From: donghyukseo Date: Tue, 19 Aug 2025 23:51:01 +0900 Subject: [PATCH 4/4] =?UTF-8?q?refactor=20:=20=EC=98=A4=ED=83=80=20?= =?UTF-8?q?=EB=B0=8F=20Transactional=20=EC=95=A0=EB=84=88=ED=85=8C?= =?UTF-8?q?=EC=9D=B4=EC=85=98=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/notification/code/NotificationErrorCode.java | 2 +- .../domain/post/service/query/PostQueryServiceImpl.java | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/naughty/tuzamate/domain/notification/code/NotificationErrorCode.java b/src/main/java/naughty/tuzamate/domain/notification/code/NotificationErrorCode.java index baedca1..e58c988 100644 --- a/src/main/java/naughty/tuzamate/domain/notification/code/NotificationErrorCode.java +++ b/src/main/java/naughty/tuzamate/domain/notification/code/NotificationErrorCode.java @@ -9,7 +9,7 @@ @Getter public enum NotificationErrorCode implements BaseErrorCode { - NOTIFICATION_NOT_FOUND(HttpStatus.NOT_FOUND, "NOTIFICATIONT404", "알림이 존재하지 않습니다."),; + NOTIFICATION_NOT_FOUND(HttpStatus.NOT_FOUND, "NOTIFICATION404", "알림이 존재하지 않습니다."),; private final HttpStatus status; private final String code; diff --git a/src/main/java/naughty/tuzamate/domain/post/service/query/PostQueryServiceImpl.java b/src/main/java/naughty/tuzamate/domain/post/service/query/PostQueryServiceImpl.java index 0a3383f..724bdd2 100644 --- a/src/main/java/naughty/tuzamate/domain/post/service/query/PostQueryServiceImpl.java +++ b/src/main/java/naughty/tuzamate/domain/post/service/query/PostQueryServiceImpl.java @@ -32,6 +32,7 @@ public class PostQueryServiceImpl implements PostQueryService { private final PostScrapRepository postScrapRepository; @Override + @Transactional public PostResDTO.PostDTO getPost(Long postId, PrincipalDetails principalDetails) { Post post = postRepository.findById(postId) .orElseThrow(() -> new CustomException(PostErrorCode.POST_NOT_FOUND));