Skip to content

Commit

Permalink
Merge pull request #95 from dongkyun0713/dongkyun
Browse files Browse the repository at this point in the history
조회수 계산 수정
  • Loading branch information
dongkyun0713 authored Feb 26, 2024
2 parents 5b9018b + c06450a commit 65654de
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ public void addExperience(User questionAuthor, User answerAuthor, int experience

// 경험치 차감
@Transactional
public void deductExperience(User user, int deductedExperience) {
public void deductExperience(User user, Integer deductedExperience) {
Integer currentExperience = user.getCurrentExperience();

if (deductedExperience > currentExperience) {
throw new CustomException(ErrorCode.INSUFFICIENT_EXPERIENCE);
}

int newCurrentExperience = currentExperience - deductedExperience;
Integer newCurrentExperience = currentExperience - deductedExperience;
user.setCurrentExperience(newCurrentExperience);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ private void createOrUpdatePostViewsCookie(HttpServletRequest request, HttpServl
if (postViewsCookie == null) {
postViewsCookie = new Cookie("postViews", postId);
} else {
// 쿠키가 null이 아닌 경우에도 현재 게시물을 확인하여 포함되어 있지 않으면 값을 업데이트합니다.
if (!postViewsCookie.getValue().contains(postId)) {
postViewsCookie.setValue(postViewsCookie.getValue() + postId);
}
Expand All @@ -118,6 +119,7 @@ private void createOrUpdatePostViewsCookie(HttpServletRequest request, HttpServl
response.addCookie(postViewsCookie);
}


public void updatePostViews(HttpServletRequest request, HttpServletResponse response, Long matchingPostId) {
MatchingPost matchingPost = findMatchingPostById(matchingPostId);
increaseViewCount(matchingPost);
Expand Down

0 comments on commit 65654de

Please sign in to comment.