diff --git a/src/main/java/com/soongsil/CoffeeChat/controller/PossibleDateController.java b/src/main/java/com/soongsil/CoffeeChat/controller/PossibleDateController.java index 4c1dca9..0b57007 100644 --- a/src/main/java/com/soongsil/CoffeeChat/controller/PossibleDateController.java +++ b/src/main/java/com/soongsil/CoffeeChat/controller/PossibleDateController.java @@ -4,11 +4,11 @@ import java.net.URI; import java.util.List; -import java.util.stream.Collectors; import org.springframework.http.ResponseEntity; import org.springframework.security.core.Authentication; import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; @@ -52,16 +52,16 @@ public ResponseEntity>> getPossibleDates( - Authentication authentication - ) throws Exception { + Authentication authentication, + @PathVariable("mentorId") Long mentorId + ) { return ResponseEntity.ok().body( ApiResponseGenerator.onSuccessOK( - possibleDateService.findPossibleDateListByMentor(getUserNameByAuthentication(authentication)) - ) + possibleDateService.findPossibleDateListByMentor(mentorId)) ); } } diff --git a/src/main/java/com/soongsil/CoffeeChat/dto/ApplicationCreateResponseDto.java b/src/main/java/com/soongsil/CoffeeChat/dto/ApplicationCreateResponseDto.java index 198e6c4..476b976 100644 --- a/src/main/java/com/soongsil/CoffeeChat/dto/ApplicationCreateResponseDto.java +++ b/src/main/java/com/soongsil/CoffeeChat/dto/ApplicationCreateResponseDto.java @@ -27,15 +27,15 @@ public class ApplicationCreateResponseDto { private String applicationMemo; @JsonProperty("application_date") - @Schema(type = "string", pattern = "yyyy-MM-dd") + @Schema(type = "string", pattern = "yyyy-mm-dd") private LocalDate applicationDate; @JsonProperty("application_start_time") - @Schema(type = "string", pattern = "HH-mm") + @Schema(type = "string", pattern = "hh:mm:ss") private LocalTime applicationStartTime; @JsonProperty("application_end_time") - @Schema(type = "string", pattern = "HH-mm") + @Schema(type = "string", pattern = "hh:mm:ss") private LocalTime applicationEndTime; public static ApplicationCreateResponseDto from(Application application) { diff --git a/src/main/java/com/soongsil/CoffeeChat/dto/ApplicationGetResponseDto.java b/src/main/java/com/soongsil/CoffeeChat/dto/ApplicationGetResponseDto.java index bbf7e52..a5fefd7 100644 --- a/src/main/java/com/soongsil/CoffeeChat/dto/ApplicationGetResponseDto.java +++ b/src/main/java/com/soongsil/CoffeeChat/dto/ApplicationGetResponseDto.java @@ -23,6 +23,9 @@ public class ApplicationGetResponseDto { @JsonProperty("mentee_name") private String menteeName; + @JsonProperty("mentor_name") + private String mentorName; + @JsonProperty("application_memo") private String memo; @@ -31,16 +34,17 @@ public class ApplicationGetResponseDto { private LocalDate date; @JsonProperty("application_start_time") - @Schema(type = "string", pattern = "HH-mm", example = "14:30") + @Schema(type = "string", pattern = "hh:mm:ss") private LocalTime startTime; @JsonProperty("application_end_time") - @Schema(type = "string", pattern = "HH-mm", example = "15:30") + @Schema(type = "string", pattern = "hh:mm:ss") private LocalTime endTime; - public static ApplicationGetResponseDto toDto(Application application, String menteeName) { + public static ApplicationGetResponseDto toDto(Application application, String mentorName, String menteeName) { return ApplicationGetResponseDto.builder() .applicationId(application.getId()) + .mentorName(mentorName) .menteeName(menteeName) .memo(application.getMemo()) .date(application.getPossibleDate().getDate()) diff --git a/src/main/java/com/soongsil/CoffeeChat/dto/PossibleDateCreateGetResponseDto.java b/src/main/java/com/soongsil/CoffeeChat/dto/PossibleDateCreateGetResponseDto.java index a22f9bd..0c2b600 100644 --- a/src/main/java/com/soongsil/CoffeeChat/dto/PossibleDateCreateGetResponseDto.java +++ b/src/main/java/com/soongsil/CoffeeChat/dto/PossibleDateCreateGetResponseDto.java @@ -30,11 +30,11 @@ public class PossibleDateCreateGetResponseDto { private LocalDate date; @JsonProperty("start_time") - @Schema(type = "string", pattern = "HH-mm") + @Schema(type = "string", pattern = "hh:mm:ss") private LocalTime startTime; @JsonProperty("end_time") - @Schema(type = "string", pattern = "HH-mm") + @Schema(type = "string", pattern = "hh:mm:ss") private LocalTime endTime; @JsonIgnore diff --git a/src/main/java/com/soongsil/CoffeeChat/dto/PossibleDateCreateRequestDto.java b/src/main/java/com/soongsil/CoffeeChat/dto/PossibleDateCreateRequestDto.java index 37e325a..f671c27 100644 --- a/src/main/java/com/soongsil/CoffeeChat/dto/PossibleDateCreateRequestDto.java +++ b/src/main/java/com/soongsil/CoffeeChat/dto/PossibleDateCreateRequestDto.java @@ -25,11 +25,11 @@ public class PossibleDateCreateRequestDto { private LocalDate date; @JsonProperty("start_time") - @Schema(type = "string", pattern = "HH-mm") + @Schema(type = "string", pattern = "hh:mm:ss") private LocalTime startTime; @JsonProperty("end_time") - @Schema(type = "string", pattern = "HH-mm") + @Schema(type = "string", pattern = "hh:mm:ss") private LocalTime endTime; @QueryProjection diff --git a/src/main/java/com/soongsil/CoffeeChat/service/ApplicationService.java b/src/main/java/com/soongsil/CoffeeChat/service/ApplicationService.java index 942b081..e97713a 100644 --- a/src/main/java/com/soongsil/CoffeeChat/service/ApplicationService.java +++ b/src/main/java/com/soongsil/CoffeeChat/service/ApplicationService.java @@ -227,10 +227,12 @@ public ApplicationGetResponseDto getApplication(Long applicationId) { APPLICATION_NOT_FOUND.getErrorMessage() )); User findMenteeUser = userRepository.findByMenteeId(findApplication.getMentee().getId()); + User findMentorUser = userRepository.findByMentor(findApplication.getMentor()); //TODO: toDTO 빌더 만들어두고, join으로 묶자 return ApplicationGetResponseDto.builder() .applicationId(applicationId) .menteeName(findMenteeUser.getName()) + .mentorName(findMentorUser.getName()) .memo(findApplication.getMemo()) .date(findApplication.getPossibleDate().getDate()) .startTime(findApplication.getPossibleDate().getStartTime()) @@ -260,6 +262,7 @@ public List getApplications(String username, String a // MATCHED든 UNMATCHED든 둘 중 하나 필터링 된 것들 다 반환 dtos.add(ApplicationGetResponseDto.toDto( app, + user.getName(), findMenteeUser.getName() )); } diff --git a/src/main/java/com/soongsil/CoffeeChat/service/PossibleDateService.java b/src/main/java/com/soongsil/CoffeeChat/service/PossibleDateService.java index 58b6cc1..cf0aa80 100644 --- a/src/main/java/com/soongsil/CoffeeChat/service/PossibleDateService.java +++ b/src/main/java/com/soongsil/CoffeeChat/service/PossibleDateService.java @@ -1,25 +1,25 @@ package com.soongsil.CoffeeChat.service; +import static com.soongsil.CoffeeChat.controller.exception.enums.UserErrorCode.*; + import java.util.List; import java.util.stream.Collectors; -import com.soongsil.CoffeeChat.controller.exception.CustomException; -import com.soongsil.CoffeeChat.entity.User; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import com.soongsil.CoffeeChat.controller.exception.CustomException; import com.soongsil.CoffeeChat.dto.PossibleDateCreateGetResponseDto; import com.soongsil.CoffeeChat.dto.PossibleDateCreateRequestDto; import com.soongsil.CoffeeChat.entity.Mentor; import com.soongsil.CoffeeChat.entity.PossibleDate; +import com.soongsil.CoffeeChat.entity.User; import com.soongsil.CoffeeChat.repository.PossibleDate.PossibleDateRepository; import com.soongsil.CoffeeChat.repository.User.UserRepository; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; -import static com.soongsil.CoffeeChat.controller.exception.enums.UserErrorCode.USER_NOT_FOUND; - @Service @RequiredArgsConstructor @Slf4j @@ -28,7 +28,7 @@ public class PossibleDateService { private final PossibleDateRepository possibleDateRepository; private final UserRepository userRepository; - private User findUserByUsername(String username){ + private User findUserByUsername(String username) { return userRepository.findByUsername(username) .orElseThrow(() -> new CustomException( USER_NOT_FOUND.getHttpStatusCode(), @@ -63,10 +63,7 @@ public List updatePossibleDate(List findPossibleDateListByMentor(String username) { - User user = findUserByUsername(username); - Long mentorId = user.getMentor().getId(); + public List findPossibleDateListByMentor(Long mentorId) { return possibleDateRepository.getPossibleDatesByMentorId(mentorId) .stream() .map(possibleDate -> PossibleDateCreateGetResponseDto.builder()