diff --git a/main/src/main/java/org/sopt/makers/crew/main/entity/post/Post.java b/main/src/main/java/org/sopt/makers/crew/main/entity/post/Post.java index 88e2befd..7a9fd2be 100644 --- a/main/src/main/java/org/sopt/makers/crew/main/entity/post/Post.java +++ b/main/src/main/java/org/sopt/makers/crew/main/entity/post/Post.java @@ -150,6 +150,10 @@ public void decreaseLikeCount() { this.likeCount--; } + public void increaseViewCount() { + this.viewCount++; + } + public void isWriter(Integer userId) { if (!this.userId.equals(userId)) { throw new ForbiddenException(FORBIDDEN_EXCEPTION.getErrorCode()); diff --git a/main/src/main/java/org/sopt/makers/crew/main/post/v2/service/PostV2ServiceImpl.java b/main/src/main/java/org/sopt/makers/crew/main/post/v2/service/PostV2ServiceImpl.java index 03357acc..ebdde882 100644 --- a/main/src/main/java/org/sopt/makers/crew/main/post/v2/service/PostV2ServiceImpl.java +++ b/main/src/main/java/org/sopt/makers/crew/main/post/v2/service/PostV2ServiceImpl.java @@ -166,13 +166,16 @@ public PostV2GetPostsResponseDto getPosts(PostGetPostsCommand queryCommand, Inte /** * 모임 게시글 단건 조회 * - * @throws 400 - * @apiNote 모임에 속한 유저만 작성 가능 + * @throws 400 모임이 존재하지 않은 경우 + * @apiNote 게시믈 조회 시, 조회수가 1 증가한다. */ @Override - @Transactional(readOnly = true) + @Transactional public PostDetailBaseDto getPost(Integer userId, Integer postId) { - return postRepository.findPost(userId, postId); + PostDetailBaseDto responseDto = postRepository.findPost(userId, postId); + Post post = postRepository.findByIdOrThrow(postId); + post.increaseViewCount(); + return responseDto; } @Override