From 5001be70a173cfc0f423d5e2d6c52a2f610794f3 Mon Sep 17 00:00:00 2001 From: oxdjww Date: Tue, 24 Sep 2024 19:50:48 +0900 Subject: [PATCH 1/3] =?UTF-8?q?refactor:=20dto=20=EC=8B=9C=EA=B0=84=20?= =?UTF-8?q?=EC=96=91=EC=8B=9D=20=ED=86=B5=EC=9D=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CoffeeChat/dto/ApplicationCreateResponseDto.java | 6 +++--- .../soongsil/CoffeeChat/dto/ApplicationGetResponseDto.java | 4 ++-- .../CoffeeChat/dto/PossibleDateCreateGetResponseDto.java | 4 ++-- .../CoffeeChat/dto/PossibleDateCreateRequestDto.java | 4 ++-- 4 files changed, 9 insertions(+), 9 deletions(-) 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..13ff07d 100644 --- a/src/main/java/com/soongsil/CoffeeChat/dto/ApplicationGetResponseDto.java +++ b/src/main/java/com/soongsil/CoffeeChat/dto/ApplicationGetResponseDto.java @@ -31,11 +31,11 @@ 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) { 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 From c6d1f12c1acf4b5968d196d7d677e879a6560b8c Mon Sep 17 00:00:00 2001 From: oxdjww Date: Tue, 24 Sep 2024 20:08:04 +0900 Subject: [PATCH 2/3] =?UTF-8?q?refactor:=20COGO=20=EC=A1=B0=ED=9A=8C=20?= =?UTF-8?q?=EC=8B=9C=20=EB=A9=98=ED=86=A0=20=EC=9D=B4=EB=A6=84=EB=8F=84=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../soongsil/CoffeeChat/dto/ApplicationGetResponseDto.java | 6 +++++- .../com/soongsil/CoffeeChat/service/ApplicationService.java | 3 +++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/soongsil/CoffeeChat/dto/ApplicationGetResponseDto.java b/src/main/java/com/soongsil/CoffeeChat/dto/ApplicationGetResponseDto.java index 13ff07d..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; @@ -38,9 +41,10 @@ public class ApplicationGetResponseDto { @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/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() )); } From 0548c6c3ece0aa4583ed2889b32a18e2454595ed Mon Sep 17 00:00:00 2001 From: oxdjww Date: Tue, 24 Sep 2024 20:26:28 +0900 Subject: [PATCH 3/3] =?UTF-8?q?refactor:=20=EB=A9=98=ED=86=A0=20=EC=95=84?= =?UTF-8?q?=EC=9D=B4=EB=94=94=EB=A1=9C=20=EA=B0=80=EB=8A=A5=EC=8B=9C?= =?UTF-8?q?=EA=B0=84=20=EC=A1=B0=ED=9A=8C=20=EA=B0=80=EB=8A=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/PossibleDateController.java | 12 ++++++------ .../CoffeeChat/service/PossibleDateService.java | 15 ++++++--------- 2 files changed, 12 insertions(+), 15 deletions(-) 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/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()