diff --git a/src/main/java/ollie/wecare/challenge/controller/ChallengeController.java b/src/main/java/ollie/wecare/challenge/controller/ChallengeController.java index 8d4282d..7d75a9f 100644 --- a/src/main/java/ollie/wecare/challenge/controller/ChallengeController.java +++ b/src/main/java/ollie/wecare/challenge/controller/ChallengeController.java @@ -72,7 +72,7 @@ public BaseResponse participateChallenge(@RequestBody PostChallengeReq p // 챌린지 검색 @GetMapping("/search") - public BaseResponse> getChallenges(@RequestParam(value = "searchWord", defaultValue = "", required = false) String searchWord)throws BaseException { + public BaseResponse> getChallenges(@RequestParam(value = "searchWord", defaultValue = "", required = false) String searchWord)throws BaseException { return new BaseResponse<>(challengeService.getChallenges(searchWord)); } diff --git a/src/main/java/ollie/wecare/challenge/dto/GetChallengesAdminRes.java b/src/main/java/ollie/wecare/challenge/dto/GetChallengesAdminRes.java index 33fb6e1..8436ce6 100644 --- a/src/main/java/ollie/wecare/challenge/dto/GetChallengesAdminRes.java +++ b/src/main/java/ollie/wecare/challenge/dto/GetChallengesAdminRes.java @@ -22,6 +22,7 @@ public class GetChallengesAdminRes { private Integer participantsCount; private String location; + private String locatedPlace; private String schedule; @@ -32,6 +33,7 @@ public static GetChallengesAdminRes fromChallenge(Challenge challenge) { return GetChallengesAdminRes.builder() .challengeIdx(challenge.getChallengeIdx()) .name(challenge.getName()) + .locatedPlace(challenge.getProgram().getLocatedPlace()) .participantsCount(challenge.getParticipants().size()) .location(getLocationTag(challenge.getProgram()) != null ? getLocationTag(challenge.getProgram()).getTagName() : null) .schedule(challenge.getProgram().getSchedule()) diff --git a/src/main/java/ollie/wecare/challenge/dto/GetChallengesRes.java b/src/main/java/ollie/wecare/challenge/dto/GetChallengesRes.java index e92ebc0..12caa2d 100644 --- a/src/main/java/ollie/wecare/challenge/dto/GetChallengesRes.java +++ b/src/main/java/ollie/wecare/challenge/dto/GetChallengesRes.java @@ -25,6 +25,8 @@ public class GetChallengesRes { private String schedule; + private String locatedPlace; + private Integer myAttendanceRate; private Integer totalAttendanceRate; @@ -38,6 +40,7 @@ public static GetChallengesRes fromChallenge(Challenge challenge, Integer myAtte .location(getLocationTag(challenge.getProgram()) != null ? getLocationTag(challenge.getProgram()).getTagName() : null) .schedule(challenge.getProgram().getSchedule()) .myAttendanceRate(myAttendanceRate) + .locatedPlace(challenge.getProgram().getLocatedPlace()) .totalAttendanceRate(challenge.getAttendanceRate()).build(); } diff --git a/src/main/java/ollie/wecare/challenge/dto/SearchChallengeRes.java b/src/main/java/ollie/wecare/challenge/dto/SearchChallengeRes.java new file mode 100644 index 0000000..c2b6c20 --- /dev/null +++ b/src/main/java/ollie/wecare/challenge/dto/SearchChallengeRes.java @@ -0,0 +1,31 @@ +package ollie.wecare.challenge.dto; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import ollie.wecare.challenge.entity.Challenge; + +@Data +@AllArgsConstructor +@Builder +@NoArgsConstructor +public class SearchChallengeRes { + private Long challengeIdx; + + private String name; + + private String schedule; + + private String locatedPlace; + + public static SearchChallengeRes fromChallenge(Challenge challenge) { + + return SearchChallengeRes.builder() + .challengeIdx(challenge.getChallengeIdx()) + .name(challenge.getName()) + .schedule(challenge.getProgram().getSchedule()) + .locatedPlace(challenge.getProgram().getLocatedPlace()) + .build(); + } +} diff --git a/src/main/java/ollie/wecare/challenge/service/ChallengeService.java b/src/main/java/ollie/wecare/challenge/service/ChallengeService.java index 02e9149..bbcd7b0 100644 --- a/src/main/java/ollie/wecare/challenge/service/ChallengeService.java +++ b/src/main/java/ollie/wecare/challenge/service/ChallengeService.java @@ -123,12 +123,12 @@ public void participateChallenge(PostChallengeReq postChallengeReq) throws BaseE /* * 챌린지 검색 * */ - public List getChallenges(String searchWord) { + public List getChallenges(String searchWord) { User user = userService.getUserWithValidation(); List challenges = challengeRepository.findByNameContainingAndParticipantsNotContaining(searchWord, user); return challenges.stream() .distinct() - .map(challenge -> GetChallengesRes.fromChallenge(challenge, 0)) + .map(challenge -> SearchChallengeRes.fromChallenge(challenge)) .toList(); } diff --git a/src/main/java/ollie/wecare/program/dto/GetProgramDetailRes.java b/src/main/java/ollie/wecare/program/dto/GetProgramDetailRes.java index a44c218..423cb05 100644 --- a/src/main/java/ollie/wecare/program/dto/GetProgramDetailRes.java +++ b/src/main/java/ollie/wecare/program/dto/GetProgramDetailRes.java @@ -27,6 +27,8 @@ public class GetProgramDetailRes { private String location; + private String locatedPlace; + private String category; private String host; @@ -42,6 +44,7 @@ public static GetProgramDetailRes fromProgram(Program program) { .name(program.getName()) .openDate(convertToDateDto(program.getOpenDate())) .dueDate(convertToDateDto(program.getDueDate())) + .locatedPlace(program.getLocatedPlace()) .location(getLocationTag(program) != null ? getLocationTag(program).getTagName() : null) .category(getCategoryTag(program) != null ? getCategoryTag(program).getTagName() : null) .host(program.getHost()) diff --git a/src/main/java/ollie/wecare/program/dto/PostProgramReq.java b/src/main/java/ollie/wecare/program/dto/PostProgramReq.java index 4aad3d3..87e4c77 100644 --- a/src/main/java/ollie/wecare/program/dto/PostProgramReq.java +++ b/src/main/java/ollie/wecare/program/dto/PostProgramReq.java @@ -15,6 +15,8 @@ public class PostProgramReq { private String location; + private String locatedPlace; + private String host; private String schedule; @@ -28,6 +30,7 @@ public static Program toProgram(PostProgramReq postProgramReq) { .dueDate(convertToLocalDateTime(postProgramReq.getDueDate())) .openDate(convertToLocalDateTime(postProgramReq.getOpenDate())) .host(postProgramReq.getHost()) + .locatedPlace(postProgramReq.getLocatedPlace()) .schedule(postProgramReq.getSchedule()) .description(postProgramReq.getDescription()) .build(); diff --git a/src/main/java/ollie/wecare/program/entity/Program.java b/src/main/java/ollie/wecare/program/entity/Program.java index 9ca4aee..b931ce6 100644 --- a/src/main/java/ollie/wecare/program/entity/Program.java +++ b/src/main/java/ollie/wecare/program/entity/Program.java @@ -27,7 +27,7 @@ public class Program extends BaseEntity { private LocalDateTime openDate; - //private String location; + private String locatedPlace; private String host; diff --git a/src/main/java/ollie/wecare/user/dto/LoginResponse.java b/src/main/java/ollie/wecare/user/dto/LoginResponse.java index 6dfecb5..13196f8 100644 --- a/src/main/java/ollie/wecare/user/dto/LoginResponse.java +++ b/src/main/java/ollie/wecare/user/dto/LoginResponse.java @@ -1,4 +1,4 @@ package ollie.wecare.user.dto; -public record LoginResponse(String accessToken, String refreshToken, boolean isAdmin) { +public record LoginResponse(String accessToken, String refreshToken, boolean isAdmin, Long centerIdx) { } diff --git a/src/main/java/ollie/wecare/user/service/UserService.java b/src/main/java/ollie/wecare/user/service/UserService.java index 934271a..370b607 100644 --- a/src/main/java/ollie/wecare/user/service/UserService.java +++ b/src/main/java/ollie/wecare/user/service/UserService.java @@ -84,7 +84,7 @@ public BaseResponse login(LoginRequest loginRequest) { if(!encoder.matches(loginRequest.password(), user.getPassword())) throw new BaseException(WRONG_PASSWORD); JwtDto jwtDto = authService.generateToken(user.getUserIdx()); - LoginResponse loginResponse = new LoginResponse(jwtDto.accessToken(), jwtDto.refreshToken(), user.getRole().equals(Admin)); + LoginResponse loginResponse = new LoginResponse(jwtDto.accessToken(), jwtDto.refreshToken(), user.getRole().equals(Admin), user.getCenter().getCenterIdx()); user.login(); userRepository.save(user);