Skip to content

Commit

Permalink
chore - #183 메소드명에서 필요없는 이름 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
jumining committed Jul 29, 2024
1 parent 8377bea commit 4fbb30f
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ public interface DailyChallengeJpaRepository extends JpaRepository<DailyChalleng

Optional<DailyChallenge> findByChallengeDateAndUserId(LocalDate challengeDate, Long userId);

List<DailyChallenge> findAllByChallengeIdOrderByChallengeDate(Long challengeId);
List<DailyChallenge> findAllByChallengeId(Long challengeId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public interface DailyChallengeRepository {

Optional<DailyChallenge> findByChallengeDateAndUserId(LocalDate challengeDate, Long userId);

List<DailyChallenge> findAllByChallengeIdOrderByChallengeDate(Long challengeId);
List<DailyChallenge> findAllByChallengeId(Long challengeId);

boolean existsByUserIdAndChallengeDateIn(Long userId, List<LocalDate> localDates);
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ public Optional<DailyChallenge> findByChallengeDateAndUserId(LocalDate challenge
}

@Override
public List<DailyChallenge> findAllByChallengeIdOrderByChallengeDate(Long challengeId) {
return dailyChallengeJpaRepository.findAllByChallengeIdOrderByChallengeDate(challengeId);
public List<DailyChallenge> findAllByChallengeId(Long challengeId) {
return dailyChallengeJpaRepository.findAllByChallengeId(challengeId);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import sopt.org.hmh.domain.app.domain.ChallengeApp;
import sopt.org.hmh.domain.app.service.HistoryAppService;
import sopt.org.hmh.domain.challenge.domain.Challenge;
import sopt.org.hmh.domain.challenge.service.ChallengeService;
Expand All @@ -28,22 +27,22 @@ public List<Status> addFinishedDailyChallengeHistory(Long userId, FinishedDailyC
Challenge challenge = challengeService.findByIdOrElseThrow(userService.getCurrentChallengeIdByUserId(userId));

request.finishedDailyChallenges().forEach(challengeRequest -> {
DailyChallenge dailyChallenge =
challenge.getHistoryDailyChallenges().get(challengeRequest.challengePeriodIndex());
DailyChallenge dailyChallenge = dailyChallengeService
.findDailyChallengeByChallengePeriodIndex(challenge, challengeRequest.challengePeriodIndex());
dailyChallengeService.changeStatusByCurrentStatus(dailyChallenge);
historyAppService.addHistoryApp(challenge.getApps(), challengeRequest.apps(), dailyChallenge, os);
});

return getHistoryDailyChallengesOrderByChallengeDate(challenge);
return getHistoryDailyChallenges(challenge);
}

@Transactional
public List<Status> changeDailyChallengeStatusByIsSuccess(Long userId, FinishedDailyChallengeStatusListRequest request) {
Challenge challenge = challengeService.findByIdOrElseThrow(userService.getCurrentChallengeIdByUserId(userId));

request.finishedDailyChallenges().forEach(challengeRequest -> {
DailyChallenge dailyChallenge =
challenge.getHistoryDailyChallenges().get(challengeRequest.challengePeriodIndex());
DailyChallenge dailyChallenge = dailyChallengeService
.findDailyChallengeByChallengePeriodIndex(challenge, challengeRequest.challengePeriodIndex());
if (challengeRequest.isSuccess()) {
dailyChallengeService.validateDailyChallengeStatus(dailyChallenge.getStatus(), List.of(Status.NONE));
dailyChallenge.changeStatus(Status.UNEARNED);
Expand All @@ -54,10 +53,10 @@ public List<Status> changeDailyChallengeStatusByIsSuccess(Long userId, FinishedD
}
});

return getHistoryDailyChallengesOrderByChallengeDate(challenge);
return getHistoryDailyChallenges(challenge);
}

private List<Status> getHistoryDailyChallengesOrderByChallengeDate(Challenge challenge) {
private List<Status> getHistoryDailyChallenges(Challenge challenge) {
return challenge.getHistoryDailyChallenges()
.stream()
.map(DailyChallenge::getStatus)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,12 @@ private List<DailyChallenge> createDailyChallengeByChallengePeriod(Challenge cha
.toList();
}

public List<DailyChallenge> getDailyChallengesByChallengeIdOrderByChallengeDate(Long challengeId) {
return dailyChallengeRepository.findAllByChallengeIdOrderByChallengeDate(challengeId);
public List<DailyChallenge> getDailyChallengesByChallengeId(Long challengeId) {
return dailyChallengeRepository.findAllByChallengeId(challengeId);
}

public void changeInfoOfDailyChallenges(Long challengeId, List<Status> statuses, LocalDate challengeDate) {
List<DailyChallenge> dailyChallenges = this.getDailyChallengesByChallengeIdOrderByChallengeDate(challengeId);
List<DailyChallenge> dailyChallenges = this.getDailyChallengesByChallengeId(challengeId);
changeStatusOfDailyChallenges(dailyChallenges, statuses);
changeChallengeDateOfDailyChallenges(dailyChallenges, challengeDate);
}
Expand Down

0 comments on commit 4fbb30f

Please sign in to comment.