Skip to content

Commit

Permalink
Merge pull request #203 from dongkyun0713/dongkyun
Browse files Browse the repository at this point in the history
fix(QuestionService) : 질문게시글 수정 시 경험치 차감 오류 수정
  • Loading branch information
dongkyun0713 authored Apr 3, 2024
2 parents 2cecd08 + a123980 commit c812a2d
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,20 @@ public void update(QuestionDTO.Update update, Long id, User user) throws CustomE
Question oldQuestion = questionRepository.findById(id)
.orElseThrow(() -> new CustomException(ErrorCode.QUESTION_NOT_FOUND));

if (oldQuestion.getSendExperience() > update.getSendExperience()) {
user.setCurrentExperience(
user.getCurrentExperience() + oldQuestion.getSendExperience() - update.getSendExperience());
} else {
experienceService.deductExperience(user, update.getSendExperience() - oldQuestion.getSendExperience());
}

oldQuestion.update(
update.getTitle(),
update.getContent(),
Department.valueOf(String.valueOf(update.getDepartment())),
update.getSendExperience()
);

}

@Transactional
Expand Down

0 comments on commit c812a2d

Please sign in to comment.