Skip to content

Commit

Permalink
Merge pull request #274 from HabitPay/feat/챌린지-상세-정보-조회-api-참여-요일-데이터-변경
Browse files Browse the repository at this point in the history
#273

[remove] 챌린지 상세 정보 조회 api 삭제 #273
  • Loading branch information
Han-Joon-Hyeok authored Oct 11, 2024
2 parents 3a94f52 + a6af141 commit a9feaa7
Show file tree
Hide file tree
Showing 8 changed files with 3 additions and 419 deletions.
56 changes: 0 additions & 56 deletions src/docs/asciidoc/api/challenge.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -43,62 +43,6 @@ operation::challenge/get-challenge-details[snippets='http-request,http-response,

operation::challenge/get-challenge-details-not-found-exception[snippets='http-request,http-response,response-fields']

=== 챌린지 1회 실패당 벌금 조회

첼린지 1회 실패당 벌금을 조회합니다.

operation::challenge/get-challenge-fee-per-absence[snippets='http-request,http-response,response-fields']

==== 에러 응답

===== 챌린지가 존재하지 않는 경우 (404 Not Found)

존재하지 않는 챌린지를 조회한 경우입니다.

operation::challenge/get-challenge-fee-per-absence-not-found-exception[snippets='http-request,http-response,response-fields']

=== 챌린지 전체 벌금 조회

챌린지 내에 현재까지 모인 벌금의 총합을 조회합니다.

operation::challenge/get-challenge-total-absence-fee[snippets='http-request,http-response,response-fields']

==== 에러 응답

===== 챌린지가 존재하지 않는 경우 (404 Not Found)

존재하지 않는 챌린지를 조회한 경우입니다.

operation::challenge/get-challenge-total-absence-fee-not-found-exception[snippets='http-request,http-response,response-fields']

=== 챌린지 진행 기간 조회

첼린지 진행 기간을 조회합니다.

operation::challenge/get-challenge-dates[snippets='http-request,http-response,response-fields']

==== 에러 응답

===== 챌린지가 존재하지 않는 경우 (404 Not Found)

존재하지 않는 챌린지를 조회한 경우입니다.

operation::challenge/get-challenge-dates-not-found-exception[snippets='http-request,http-response,response-fields']

=== 챌린지 참여 요일 조회

첼린지 참여 요일을 조회합니다.

operation::challenge/get-challenge-participating-days[snippets='http-request,http-response,response-fields']

==== 에러 응답

===== 챌린지가 존재하지 않는 경우 (404 Not Found)

존재하지 않는 챌린지를 조회한 경우입니다.

operation::challenge/get-challenge-participating-days-not-found-exception[snippets='http-request,http-response,response-fields']

=== 챌린지 생성

새로운 첼린지를 생성합니다.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,26 +46,6 @@ public SuccessResponse<ChallengeDetailsResponse> getChallengeDetails(@PathVariab
return challengeDetailsService.getChallengeDetails(id, user.getMember());
}

@GetMapping("/challenges/{id}/fees/absence")
public SuccessResponse<ChallengeFeePerAbsenceResponse> getChallengeFeePerAbsence(@PathVariable("id") Long id) {
return challengeDetailsService.getChallengeFeePerAbsence(id);
}

@GetMapping("/challenges/{id}/fees/absence/total")
public SuccessResponse<ChallengeTotalAbsenceFeeResponse> getChallengeTotalAbsenceFee(@PathVariable("id") Long id) {
return challengeDetailsService.getChallengeTotalAbsenceFee(id);
}

@GetMapping("/challenges/{id}/dates")
public SuccessResponse<ChallengeDatesResponse> getChallengeDates(@PathVariable("id") Long id) {
return challengeDetailsService.getChallengeDates(id);
}

@GetMapping("/challenges/{id}/participating-days")
public SuccessResponse<ChallengeParticipatingDaysResponse> getChallengeParticipatingDays(@PathVariable("id") Long id) {
return challengeDetailsService.getChallengeParticipatingDays(id);
}

@PostMapping("/challenges")
public SuccessResponse<ChallengeCreationResponse> createChallenge(@RequestBody ChallengeCreationRequest challengeCreationRequest,
@AuthenticationPrincipal CustomUserDetails user) {
Expand Down
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)
);
}
}

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit a9feaa7

Please sign in to comment.