Skip to content

Commit

Permalink
remove: 챌린지 개별 정보(1회 실패당 벌금, 챌린지 벌금 총합, 챌린지 진행 기간, 챌린지 참여 요일) 조회 서비스 삭제
Browse files Browse the repository at this point in the history
  • Loading branch information
Han-Joon-Hyeok committed Oct 11, 2024
1 parent d8a5764 commit a6af141
Showing 1 changed file with 3 additions and 38 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.habitpay.habitpay.domain.challenge.application;

import com.habitpay.habitpay.domain.challenge.domain.Challenge;
import com.habitpay.habitpay.domain.challenge.dto.*;
import com.habitpay.habitpay.domain.challenge.dto.ChallengeDetailsResponse;
import com.habitpay.habitpay.domain.challengeenrollment.dao.ChallengeEnrollmentRepository;
import com.habitpay.habitpay.domain.challengeenrollment.domain.ChallengeEnrollment;
import com.habitpay.habitpay.domain.member.domain.Member;
Expand Down Expand Up @@ -36,6 +36,7 @@ public SuccessResponse<ChallengeDetailsResponse> getChallengeDetails(Long challe
})
.toList();

// TODO: Challenge 엔티티에 totalAbsenceFee 컬럼 추가 후 Response 생성 시 전달하는 매개변수도 함께 변경 부탁드립니다. (from. joonhan)
int totalAbsenceFee = sumAllFeesOfChallenge(challenge);

return SuccessResponse.of(
Expand All @@ -49,48 +50,12 @@ public SuccessResponse<ChallengeDetailsResponse> getChallengeDetails(Long challe
);
}

public SuccessResponse<ChallengeFeePerAbsenceResponse> getChallengeFeePerAbsence(Long challengeId) {
Challenge challenge = challengeSearchService.getChallengeById(challengeId);

return SuccessResponse.of(
SuccessCode.NO_MESSAGE,
ChallengeFeePerAbsenceResponse.from(challenge)
);
}

public SuccessResponse<ChallengeTotalAbsenceFeeResponse> getChallengeTotalAbsenceFee(Long challengeId) {
Challenge challenge = challengeSearchService.getChallengeById(challengeId);
int totalAbsenceFee = sumAllFeesOfChallenge(challenge);

return SuccessResponse.of(
SuccessCode.NO_MESSAGE,
ChallengeTotalAbsenceFeeResponse.from(totalAbsenceFee)
);
}

// TODO: Challenge 엔티티에 totalAbsenceFee 컬럼 추가 후 아래의 함수 삭제 부탁드립니다. (from. joonhan)
private int sumAllFeesOfChallenge(Challenge challenge) {
List<ChallengeEnrollment> enrollmentList = challengeEnrollmentRepository.findAllByChallenge(challenge);
return enrollmentList
.stream()
.mapToInt(enrollment -> enrollment.getParticipationStat().getTotalFee())
.sum();
}

public SuccessResponse<ChallengeDatesResponse> getChallengeDates(Long challengeId) {
Challenge challenge = challengeSearchService.getChallengeById(challengeId);

return SuccessResponse.of(
SuccessCode.NO_MESSAGE,
ChallengeDatesResponse.from(challenge)
);
}

public SuccessResponse<ChallengeParticipatingDaysResponse> getChallengeParticipatingDays(Long challengeId) {
Challenge challenge = challengeSearchService.getChallengeById(challengeId);

return SuccessResponse.of(
SuccessCode.NO_MESSAGE,
ChallengeParticipatingDaysResponse.from(challenge)
);
}
}

0 comments on commit a6af141

Please sign in to comment.