Skip to content

Commit

Permalink
러너 게시글 상세 조회 시 조회수가 증가하도록 변경 (#230)
Browse files Browse the repository at this point in the history
refactor: 글 조회 시 조회수가 증가하지 않았던 문제 수정
  • Loading branch information
cookienc authored Aug 4, 2023
1 parent 5b1c0c0 commit a2186df
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ public ResponseEntity<RunnerPostResponse.Detail> readByRunnerPostId(@AuthRunnerP
@PathVariable final Long runnerPostId
) {
final RunnerPost runnerPost = runnerPostService.readByRunnerPostId(runnerPostId);
runnerPostService.increaseWatchedCount(runnerPost);

final RunnerPostResponse.Detail response = RunnerPostResponse.Detail.of(
runnerPost,
runnerPost.getRunner().equals(runner)
Expand All @@ -74,6 +76,8 @@ public ResponseEntity<RunnerPostResponse.DetailVersionTest> readByRunnerPostIdVe
@PathVariable final Long runnerPostId
) {
final RunnerPost runnerPost = runnerPostService.readByRunnerPostId(runnerPostId);
runnerPostService.increaseWatchedCount(runnerPost);

final RunnerPostResponse.DetailVersionTest response = RunnerPostResponse.DetailVersionTest.ofVersionTest(
runnerPost,
runnerPost.getRunner().equals(runner)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,13 @@ public Long createRunnerPostTest(final Runner runner, final RunnerPostCreateTest

public RunnerPost readByRunnerPostId(final Long runnerPostId) {
runnerPostTagRepository.joinTagByRunnerPostId(runnerPostId);
final RunnerPost findRunnerPost = runnerPostRepository.joinMemberByRunnerPostId(runnerPostId)
return runnerPostRepository.joinMemberByRunnerPostId(runnerPostId)
.orElseThrow(() -> new RunnerPostBusinessException("RunnerPost 의 식별자값으로 러너 게시글을 조회할 수 없습니다."));
}

findRunnerPost.increaseWatchedCount();

return findRunnerPost;
@Transactional
public void increaseWatchedCount(final RunnerPost runnerPost) {
runnerPost.increaseWatchedCount();
}

@Transactional
Expand Down Expand Up @@ -196,7 +197,7 @@ public Long updateRunnerPost(final Long runnerPostId, final Runner runner, final

return runnerPost.getId();
}

public List<RunnerPost> readAllRunnerPosts() {
return runnerPostRepository.findAllByOrderByCreatedAtDesc();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
import touch.baton.domain.common.vo.WatchedCount;
import touch.baton.domain.member.Member;
import touch.baton.domain.member.vo.Company;
import touch.baton.domain.member.vo.SocialId;
import touch.baton.domain.member.vo.GithubUrl;
import touch.baton.domain.member.vo.ImageUrl;
import touch.baton.domain.member.vo.MemberName;
import touch.baton.domain.member.vo.OauthId;
import touch.baton.domain.member.vo.SocialId;
import touch.baton.domain.runner.Runner;
import touch.baton.domain.runnerpost.RunnerPost;
import touch.baton.domain.runnerpost.exception.RunnerPostBusinessException;
Expand Down

0 comments on commit a2186df

Please sign in to comment.