Skip to content

Commit

Permalink
fix: 내가 참가한 챌린지 조회 api - 인증 가능한 챌린지만 리턴되도록
Browse files Browse the repository at this point in the history
  • Loading branch information
daeunkwak committed Sep 7, 2023
1 parent 72123bf commit 2a45e96
Showing 1 changed file with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@

import java.io.IOException;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.TextStyle;
import java.time.temporal.ChronoUnit;
import java.time.temporal.Temporal;
Expand Down Expand Up @@ -91,21 +92,35 @@ public ResponseEntity<CommonResponse> createSuccessExampleImages(@Parameter(hidd
}

@Tag(name = "challenge", description = "챌린지 API")
@Operation(summary = "내가 참가한 챌린지 리스트 조회 api")
@Operation(summary = "내가 참가한 챌린지 리스트 조회 api - 인증하기")
@GetMapping("/participate")
public ResponseEntity<List<MyParticipateChallengeResponseDto>> getMyParticipateChallenge(@Parameter(hidden = true) @RequestMemberId Long memberId) {

List<Participate> participates = challengeService.getMyParticipateChallenge(memberId);

List<MyParticipateChallengeResponseDto> result = new ArrayList<>();
for(Participate participate : participates){
if(participate.getChallenge().getJudgeStatus().equals(JudgeStatus.COMPLETE)){
if(participate.getChallenge().getJudgeStatus().equals(JudgeStatus.COMPLETE) && participate.getParticipateStatus().equals(ParticipateStatus.ONGOING) && !isCertifiedToday(participate)){
result.add(MyParticipateChallengeResponseDto.from(participate.getChallenge(), String.valueOf(participate.getParticipateStatus())));
}
}
return ResponseEntity.ok(result);
}

private Boolean isCertifiedToday(Participate participate){

log.info("localdate 1 ::::: " + LocalDate.now());

for(Certify certify : participate.getCertifies()){
if(certify.getCreatedDate().toLocalDate().equals(LocalDate.now())){
log.info("localdate 2 ::::: " + certify.getCreatedDate().toLocalDate());
return true;
}
}

return false;
}

@Tag(name = "home", description = "홈(둘러보기) API")
@Operation(summary = "홈 - 인기 챌린지, 공식 챌린지 조회 api")
@GetMapping("/home")
Expand Down

0 comments on commit 2a45e96

Please sign in to comment.