Skip to content

Commit

Permalink
Merge pull request #5 from PoolC/dev
Browse files Browse the repository at this point in the history
fix:뱃지를 받은 적이 없는 경우에만 뱃지 부여
  • Loading branch information
jimmy0006 authored Aug 5, 2024
2 parents 6912726 + adf22fa commit 1929c7f
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/main/java/org/poolc/api/badge/service/BadgeService.java
Original file line number Diff line number Diff line change
Expand Up @@ -138,16 +138,18 @@ public Badge getBadgeByBadgeId(Long badgeId){
return badgeRepository.findBadgeById(badgeId).get();
}

//뱃지가 존재하는 경우에만 지급함.
//뱃지가 존재하고, 해당 뱃지를 받은 적이 없을 경우에만 지급함
public void badgeGiver(Member member, Long badgeId){
if(duplicateBadgeLogCheck(badgeId, member)&&badgeRepository.findBadgeById(badgeId).isPresent()){
Badge badge = getBadgeByBadgeId(badgeId);
badgeLogRepository.save(BadgeLog.builder()
.member(member)
.date(LocalDate.now())
.badge(badge)
.build());
notificationService.createBadgeNotification(member);
if(badgeLogRepository.findBadgeLogByUUID(member.getUUID(),badgeId).isEmpty()) {
Badge badge = getBadgeByBadgeId(badgeId);
badgeLogRepository.save(BadgeLog.builder()
.member(member)
.date(LocalDate.now())
.badge(badge)
.build());
notificationService.createBadgeNotification(member);
}
}
}
}

0 comments on commit 1929c7f

Please sign in to comment.