Skip to content

Commit

Permalink
Merge pull request #40 from CSID-DGU/develop
Browse files Browse the repository at this point in the history
[Fix] μŠ€νƒ¬ν”„ 증가 μ œμ–΄
  • Loading branch information
saokiritoni authored Dec 2, 2024
2 parents cfb43f4 + 1b21be1 commit c1e4094
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public void completeMission(Long userId, LocalDate date) {

// λͺ¨λ“  λ―Έμ…˜μ΄ μ™„λ£Œλ˜μ—ˆλŠ”μ§€ 확인
if (!quest.isAllMissionsCompleted()) {
throw new IllegalStateException("λͺ¨λ“  λ―Έμ…˜μ΄ μ™„λ£Œλ˜μ§€ μ•Šμ•˜μŠ΅λ‹ˆλ‹€.");
return; // λ―Έμ…˜μ΄ μ™„λ£Œλ˜μ§€ μ•Šμ•˜μœΌλ©΄ 아무 λ™μž‘λ„ ν•˜μ§€ μ•ŠμŒ
}

// μŠ€νƒ¬ν”„ 증가
Expand All @@ -47,6 +47,14 @@ private void incrementStamp(Long userId, LocalDate date) {
Stamp stamp = stampRepository.findByUser_UserIdAndWeekNumberAndYear(userId, weekNumber, year)
.orElseGet(() -> new Stamp(user, weekNumber, year));

// 였늘 λ‚ μ§œμ— ν•΄λ‹Ήν•˜λŠ” μŠ€νƒ¬ν”„κ°€ 이미 μ±„μ›Œμ‘ŒλŠ”μ§€ 확인
int todayDayOfWeek = date.getDayOfWeek().getValue(); // μ›”μš”μΌ(1) ~ μΌμš”μΌ(7)
if (stamp.getCount() >= todayDayOfWeek) {
// 이미 μ±„μ›Œμ Έ μžˆλŠ” 경우 λ©”μ„œλ“œ μ’…λ£Œ
return;
}

// μŠ€νƒ¬ν”„λ₯Ό μ¦κ°€μ‹œν‚΄
stamp.incrementStamp();
stampRepository.save(stamp);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

@Slf4j
@RequiredArgsConstructor
@CrossOrigin(origins = "http://localhost:3000")
@CrossOrigin(origins = "https://2024-2-oss-proj-osori-fe.vercel.app")
@RestController
@RequestMapping("/api/users")
public class UserController {
Expand Down

0 comments on commit c1e4094

Please sign in to comment.