Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 조회수 증가 로직 오류 해결 #454

Merged
merged 2 commits into from
Oct 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading