Skip to content

Commit

Permalink
feat - #188 success api에도 적용
Browse files Browse the repository at this point in the history
  • Loading branch information
jumining committed Aug 19, 2024
1 parent 507229d commit 7aa4633
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,6 @@ public ResponseEntity<BaseResponse<ChallengeStatusesResponse>> orderChangeStatus
return ResponseEntity
.status(DailyChallengeSuccess.SEND_FINISHED_DAILY_CHALLENGE_SUCCESS.getHttpStatus())
.body(BaseResponse.success(DailyChallengeSuccess.SEND_FINISHED_DAILY_CHALLENGE_SUCCESS,
new ChallengeStatusesResponse(dailyChallengeFacade.changeDailyChallengeStatusByIsSuccess(userId, request))));
new ChallengeStatusesResponse(dailyChallengeFacade.changeDailyChallengeStatusByIsSuccess(userId, request, timeZone))));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public List<Status> addFinishedDailyChallengeHistory(Long userId, FinishedDailyC

request.finishedDailyChallenges().forEach(challengeRequest -> {
dailyChallengeService.validatePeriodIndex(challengeRequest.challengePeriodIndex(), todayIndex);

DailyChallenge dailyChallenge = dailyChallengeService
.findDailyChallengeByChallengePeriodIndex(challenge, challengeRequest.challengePeriodIndex());
dailyChallengeService.changeStatusByCurrentStatus(dailyChallenge);
Expand All @@ -41,10 +42,13 @@ public List<Status> addFinishedDailyChallengeHistory(Long userId, FinishedDailyC
}

@Transactional
public List<Status> changeDailyChallengeStatusByIsSuccess(Long userId, FinishedDailyChallengeStatusListRequest request) {
public List<Status> changeDailyChallengeStatusByIsSuccess(Long userId, FinishedDailyChallengeStatusListRequest request, String timeZone) {
Challenge challenge = challengeService.findByIdOrElseThrow(userService.getCurrentChallengeIdByUserId(userId));
Integer todayIndex = dailyChallengeService.calculateTodayIndex(challenge, LocalDate.now(ZoneId.of(timeZone)));

request.finishedDailyChallenges().forEach(challengeRequest -> {
dailyChallengeService.validatePeriodIndex(challengeRequest.challengePeriodIndex(), todayIndex);

DailyChallenge dailyChallenge = dailyChallengeService
.findDailyChallengeByChallengePeriodIndex(challenge, challengeRequest.challengePeriodIndex());
if (challengeRequest.isSuccess()) {
Expand Down

0 comments on commit 7aa4633

Please sign in to comment.