Skip to content

Commit

Permalink
Merge pull request #284 from 42organization/GGBE4-85--UserGameCoinRes…
Browse files Browse the repository at this point in the history
…ultDto-error

[GGBE4-85--UserGameCoinResultDto-error] UserGameCoinResultDto error 수정
  • Loading branch information
kylew1004 authored Sep 19, 2023
2 parents 78ce437 + 7e34ed2 commit b38513d
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public int addAttendanceCoin(User user){
if (coinHistoryService.hasAttendedToday(user))
throw new UserAlreadyAttendanceException();
int coinIncrement = coinPolicyRepository.findTopByOrderByCreatedAtDesc()
.orElseThrow(() -> new CoinPolicyNotFoundException()).getAttendance();
.orElseThrow(CoinPolicyNotFoundException::new).getAttendance();
user.addGgCoin(coinIncrement);
coinHistoryService.addAttendanceCoinHistory(user);
return coinIncrement;
Expand Down Expand Up @@ -58,7 +58,8 @@ public void giftItemCoin(Item item, Integer price, User user, User giftTarget){
@Transactional
public UserGameCoinResultDto addNormalGameCoin(Long userId) {
User user = userRepository.findById(userId).orElseThrow(UserNotFoundException::new);
int coinIncrement = coinPolicyRepository.findTopByOrderByCreatedAtDesc().getNormal();
int coinIncrement = coinPolicyRepository.findTopByOrderByCreatedAtDesc()
.orElseThrow(CoinPolicyNotFoundException::new).getNormal();

user.addGgCoin(coinIncrement);
coinHistoryService.addNormalCoin(user);
Expand All @@ -84,9 +85,9 @@ private boolean userIsWinner(Long gameId, User user) {

for(Team team: teams) {
for (TeamUser teamUser : team.getTeamUsers()){
if (teamUser.getUser().getId() == user.getId() && team.getWin() == true)
if (teamUser.getUser().getId() == user.getId() && team.getWin())
return true;
else if (teamUser.getUser().getId() == user.getId() && team.getWin() == false)
else if (teamUser.getUser().getId() == user.getId() && !team.getWin())
return false;
}
}
Expand Down

0 comments on commit b38513d

Please sign in to comment.