diff --git a/src/main/java/ollie/wecare/challenge/dto/GetChallengesRes.java b/src/main/java/ollie/wecare/challenge/dto/GetChallengesRes.java index 12caa2d..3a5ef98 100644 --- a/src/main/java/ollie/wecare/challenge/dto/GetChallengesRes.java +++ b/src/main/java/ollie/wecare/challenge/dto/GetChallengesRes.java @@ -5,30 +5,18 @@ import lombok.Data; import lombok.NoArgsConstructor; import ollie.wecare.challenge.entity.Challenge; -import ollie.wecare.common.enums.TagEnum; -import ollie.wecare.program.entity.Program; -import ollie.wecare.program.entity.Tag; @Data -@AllArgsConstructor @Builder +@AllArgsConstructor @NoArgsConstructor public class GetChallengesRes { - private Long challengeIdx; - private String name; - private Integer participantsCount; - - private String location; - private String schedule; - private String locatedPlace; - private Integer myAttendanceRate; - private Integer totalAttendanceRate; public static GetChallengesRes fromChallenge(Challenge challenge, Integer myAttendanceRate) { @@ -37,19 +25,9 @@ public static GetChallengesRes fromChallenge(Challenge challenge, Integer myAtte .challengeIdx(challenge.getChallengeIdx()) .name(challenge.getName()) .participantsCount(challenge.getParticipants().size()) - .location(getLocationTag(challenge.getProgram()) != null ? getLocationTag(challenge.getProgram()).getTagName() : null) .schedule(challenge.getProgram().getSchedule()) .myAttendanceRate(myAttendanceRate) .locatedPlace(challenge.getProgram().getLocatedPlace()) .totalAttendanceRate(challenge.getAttendanceRate()).build(); } - - private static TagEnum getLocationTag(Program program) { - return program.getTags().stream() - .map(Tag::getName) - .filter(tagEnum -> tagEnum.getParent() == TagEnum.LOCATION) - .findFirst() - .orElse(null); - } - } diff --git a/src/main/java/ollie/wecare/challenge/service/ChallengeService.java b/src/main/java/ollie/wecare/challenge/service/ChallengeService.java index 30ccac8..1034d9c 100644 --- a/src/main/java/ollie/wecare/challenge/service/ChallengeService.java +++ b/src/main/java/ollie/wecare/challenge/service/ChallengeService.java @@ -34,19 +34,17 @@ public class ChallengeService { private final ChallengeAttendanceRepository challengeAttendanceRepository; private final UserRepository userRepository; private final ChallengeRepository challengeRepository; - private final UserService userService; // 참여중인 챌린지 목록 조회 - public BaseResponse> getMyChallenges(Long userIdx) throws BaseException { + public BaseResponse> getMyChallenges(Long userIdx) { User user = userRepository.findByUserIdxAndStatusEquals(userIdx, ACTIVE).orElseThrow(() -> new BaseException(INVALID_USER_IDX)); - if(user.getRole().equals(Role.Challenger)){ + if (user.getRole().equals(Role.Challenger)){ return new BaseResponse<>(challengeRepository.findByParticipantsContaining(user).stream() .map(challenge -> GetChallengesRes.fromChallenge(challenge, calculateMyAchievementRate(user, challenge))) .distinct() .toList()); - } - else { // 관리자 + } else { // 관리자 return new BaseResponse<>(challengeRepository.findByAdmin(user).stream() .map(challenge -> GetChallengesRes.fromChallenge(challenge, calculateMyAchievementRate(user, challenge))) .distinct() @@ -55,7 +53,7 @@ public BaseResponse> getMyChallenges(Long userIdx) throws } - public BaseResponse> getMyChallengesAdmin(Long userIdx) throws BaseException { + public BaseResponse> getMyChallengesAdmin(Long userIdx) { User user = userRepository.findByUserIdxAndStatusEquals(userIdx, ACTIVE).orElseThrow(() -> new BaseException(INVALID_USER_IDX)); if(user.getRole().equals(Role.Admin)){ return new BaseResponse<>(challengeRepository.findByAdmin(user).stream()