From 3744f8ca7ff534213dcda6bec16b810ce0c0102e Mon Sep 17 00:00:00 2001 From: ay-eonii Date: Mon, 6 Nov 2023 12:55:22 +0900 Subject: [PATCH 01/24] =?UTF-8?q?RAC-103=20feat:=20=EB=8C=80=ED=95=99?= =?UTF-8?q?=EC=9B=90=EC=83=9D=20=EB=A9=98=ED=86=A0=EB=A7=81=20=EB=AA=A9?= =?UTF-8?q?=EB=A1=9D=20response=20=EB=B0=8F=20=EB=A7=A4=ED=8D=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/res/SeniorMentoringResponse.java | 14 ++++++++++++++ .../application/mapper/MentoringMapper.java | 10 ++++++++++ 2 files changed, 24 insertions(+) create mode 100644 src/main/java/com/postgraduate/domain/mentoring/application/dto/res/SeniorMentoringResponse.java diff --git a/src/main/java/com/postgraduate/domain/mentoring/application/dto/res/SeniorMentoringResponse.java b/src/main/java/com/postgraduate/domain/mentoring/application/dto/res/SeniorMentoringResponse.java new file mode 100644 index 00000000..b06134dd --- /dev/null +++ b/src/main/java/com/postgraduate/domain/mentoring/application/dto/res/SeniorMentoringResponse.java @@ -0,0 +1,14 @@ +package com.postgraduate.domain.mentoring.application.dto.res; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; + +@Builder +@AllArgsConstructor +@Getter +public class SeniorMentoringResponse { + private String nickname; + private String[] dates; + private int term; +} diff --git a/src/main/java/com/postgraduate/domain/mentoring/application/mapper/MentoringMapper.java b/src/main/java/com/postgraduate/domain/mentoring/application/mapper/MentoringMapper.java index dc0bafdf..2a1bf754 100644 --- a/src/main/java/com/postgraduate/domain/mentoring/application/mapper/MentoringMapper.java +++ b/src/main/java/com/postgraduate/domain/mentoring/application/mapper/MentoringMapper.java @@ -3,6 +3,7 @@ import com.postgraduate.domain.mentoring.application.dto.AppliedMentoringInfo; import com.postgraduate.domain.mentoring.application.dto.req.MentoringApplyRequest; import com.postgraduate.domain.mentoring.application.dto.res.AppliedMentoringDetailResponse; +import com.postgraduate.domain.mentoring.application.dto.res.SeniorMentoringResponse; import com.postgraduate.domain.mentoring.domain.entity.Mentoring; import com.postgraduate.domain.senior.domain.entity.Senior; import com.postgraduate.domain.user.domain.entity.User; @@ -63,4 +64,13 @@ public static Mentoring mapToMentoring(User user, Senior senior, MentoringApplyR .date(request.getDate()) .build(); } + + public static SeniorMentoringResponse mapToSeniorMentoring(Mentoring mentoring) { + String[] dates = mentoring.getDate().split(","); + return SeniorMentoringResponse.builder() + .nickname(mentoring.getUser().getNickName()) + .dates(dates) + .term(mentoring.getSenior().getTerm()) + .build(); + } } From caa4cc1c8314e6d8f374457abbd16a1ff2ead48d Mon Sep 17 00:00:00 2001 From: ay-eonii Date: Mon, 6 Nov 2023 12:55:29 +0900 Subject: [PATCH 02/24] =?UTF-8?q?RAC-103=20feat:=20=EB=8C=80=ED=95=99?= =?UTF-8?q?=EC=9B=90=EC=83=9D=20=EB=A9=98=ED=86=A0=EB=A7=81=20=EC=A1=B0?= =?UTF-8?q?=ED=9A=8C=20=EC=84=9C=EB=B9=84=EC=8A=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mentoring/domain/repository/MentoringRepository.java | 2 ++ .../domain/mentoring/domain/service/MentoringGetService.java | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/src/main/java/com/postgraduate/domain/mentoring/domain/repository/MentoringRepository.java b/src/main/java/com/postgraduate/domain/mentoring/domain/repository/MentoringRepository.java index dc839f7a..7b86983c 100644 --- a/src/main/java/com/postgraduate/domain/mentoring/domain/repository/MentoringRepository.java +++ b/src/main/java/com/postgraduate/domain/mentoring/domain/repository/MentoringRepository.java @@ -2,6 +2,7 @@ import com.postgraduate.domain.mentoring.domain.entity.Mentoring; import com.postgraduate.domain.mentoring.domain.entity.constant.Status; +import com.postgraduate.domain.senior.domain.entity.Senior; import com.postgraduate.domain.user.domain.entity.User; import org.springframework.data.jpa.repository.JpaRepository; @@ -11,4 +12,5 @@ public interface MentoringRepository extends JpaRepository { Optional findByMentoringIdAndDeletedAtIsNull(Long mentoringId); Optional> findAllByUserAndStatusAndDeletedAtIsNull(User user, Status status); + Optional> findAllBySeniorAndStatusAndDeletedAtIsNull(Senior senior, Status status); } diff --git a/src/main/java/com/postgraduate/domain/mentoring/domain/service/MentoringGetService.java b/src/main/java/com/postgraduate/domain/mentoring/domain/service/MentoringGetService.java index efabf8c0..7c144be0 100644 --- a/src/main/java/com/postgraduate/domain/mentoring/domain/service/MentoringGetService.java +++ b/src/main/java/com/postgraduate/domain/mentoring/domain/service/MentoringGetService.java @@ -4,6 +4,7 @@ import com.postgraduate.domain.mentoring.domain.entity.constant.Status; import com.postgraduate.domain.mentoring.domain.repository.MentoringRepository; import com.postgraduate.domain.mentoring.exception.MentoringNotFoundException; +import com.postgraduate.domain.senior.domain.entity.Senior; import com.postgraduate.domain.user.domain.entity.User; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; @@ -20,6 +21,10 @@ public List mentoringByUser(User user, Status status) { return mentoringRepository.findAllByUserAndStatusAndDeletedAtIsNull(user, status).orElse(new ArrayList<>()); } + public List mentoringBySenior(Senior senior, Status status) { + return mentoringRepository.findAllBySeniorAndStatusAndDeletedAtIsNull(senior, status).orElse(new ArrayList<>()); + } + public Mentoring byMentoringId(Long mentoringId) { return mentoringRepository.findByMentoringIdAndDeletedAtIsNull(mentoringId).orElseThrow(MentoringNotFoundException::new); } From c669ebe30b89234bf5d5f1ff9e5f98faf80d103e Mon Sep 17 00:00:00 2001 From: ay-eonii Date: Mon, 6 Nov 2023 12:55:38 +0900 Subject: [PATCH 03/24] =?UTF-8?q?RAC-103=20feat:=20=EB=8C=80=ED=95=99?= =?UTF-8?q?=EC=9B=90=EC=83=9D=20=EB=A9=98=ED=86=A0=EB=A7=81=20=EC=A1=B0?= =?UTF-8?q?=ED=9A=8C=20=EC=96=B4=ED=94=8C=EB=A6=AC=EC=BC=80=EC=9D=B4?= =?UTF-8?q?=EC=85=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../application/usecase/MentoringInfoUseCase.java | 14 ++++++++++++++ .../presentation/MentoringController.java | 10 ++++++++++ 2 files changed, 24 insertions(+) diff --git a/src/main/java/com/postgraduate/domain/mentoring/application/usecase/MentoringInfoUseCase.java b/src/main/java/com/postgraduate/domain/mentoring/application/usecase/MentoringInfoUseCase.java index 9d0e457d..e1cc93d4 100644 --- a/src/main/java/com/postgraduate/domain/mentoring/application/usecase/MentoringInfoUseCase.java +++ b/src/main/java/com/postgraduate/domain/mentoring/application/usecase/MentoringInfoUseCase.java @@ -3,10 +3,13 @@ import com.postgraduate.domain.mentoring.application.dto.res.AppliedMentoringDetailResponse; import com.postgraduate.domain.mentoring.application.dto.res.AppliedMentoringResponse; import com.postgraduate.domain.mentoring.application.dto.AppliedMentoringInfo; +import com.postgraduate.domain.mentoring.application.dto.res.SeniorMentoringResponse; import com.postgraduate.domain.mentoring.application.mapper.MentoringMapper; import com.postgraduate.domain.mentoring.domain.entity.Mentoring; import com.postgraduate.domain.mentoring.domain.entity.constant.Status; import com.postgraduate.domain.mentoring.domain.service.MentoringGetService; +import com.postgraduate.domain.senior.domain.entity.Senior; +import com.postgraduate.domain.senior.domain.service.SeniorGetService; import com.postgraduate.domain.user.domain.entity.User; import com.postgraduate.global.auth.AuthDetails; import com.postgraduate.global.config.security.util.SecurityUtils; @@ -16,6 +19,7 @@ import java.util.ArrayList; import java.util.List; +import java.util.stream.Collectors; @Service @Transactional @@ -23,6 +27,7 @@ public class MentoringInfoUseCase { private final MentoringGetService mentoringGetService; private final CheckIsMyMentoringUseCase checkIsMyMentoringUseCase; + private final SeniorGetService seniorGetService; private final SecurityUtils securityUtils; /** * securityUtils 이후 수정 @@ -35,6 +40,15 @@ public AppliedMentoringResponse getMentorings(Status status, AuthDetails authDet return getCategories(status, mentorings); } + public List getSeniorMentorings(Status status, AuthDetails authDetails) { + User user = securityUtils.getLoggedInUser(authDetails); + Senior senior = seniorGetService.byUser(user); + + List mentorings = mentoringGetService.mentoringBySenior(senior, status); + return mentorings.stream().map(mentoring -> + MentoringMapper.mapToSeniorMentoring(mentoring)).collect(Collectors.toList()); + } + private AppliedMentoringResponse getCategories(Status status, List mentorings) { List appliedMentoringInfos = new ArrayList<>(); diff --git a/src/main/java/com/postgraduate/domain/mentoring/presentation/MentoringController.java b/src/main/java/com/postgraduate/domain/mentoring/presentation/MentoringController.java index 8587b4c7..09807cd8 100644 --- a/src/main/java/com/postgraduate/domain/mentoring/presentation/MentoringController.java +++ b/src/main/java/com/postgraduate/domain/mentoring/presentation/MentoringController.java @@ -4,6 +4,7 @@ import com.postgraduate.domain.mentoring.application.dto.req.MentoringStatusRequest; import com.postgraduate.domain.mentoring.application.dto.res.AppliedMentoringDetailResponse; import com.postgraduate.domain.mentoring.application.dto.res.AppliedMentoringResponse; +import com.postgraduate.domain.mentoring.application.dto.res.SeniorMentoringResponse; import com.postgraduate.domain.mentoring.application.usecase.MentoringApplyUseCase; import com.postgraduate.domain.mentoring.application.usecase.MentoringInfoUseCase; import com.postgraduate.domain.mentoring.application.usecase.MentoringManageUseCase; @@ -16,6 +17,8 @@ import org.springframework.security.core.annotation.AuthenticationPrincipal; import org.springframework.web.bind.annotation.*; +import java.util.List; + import static com.postgraduate.domain.mentoring.presentation.constant.MentoringResponseCode.*; import static com.postgraduate.domain.mentoring.presentation.constant.MentoringResponseMessage.*; @@ -57,4 +60,11 @@ public ResponseDto updateMentoringStatus(@AuthenticationPrincipal AuthDetails au updateUseCase.updateStatus(authDetails, mentoringId, request); return ResponseDto.create(MENTORING_UPDATE.getCode(), UPDATE_MENTORING.getMessage()); } + + @GetMapping("/senior/me") + @Operation(summary = "[대학원생] 신청받은 멘토링 목록 조회", description = "대학원생이 신청받은 멘토링 목록을 조회합니다.") + public ResponseDto> getSeniorMentorings(@RequestParam Status status, @AuthenticationPrincipal AuthDetails authDetails) { + List seniorMentorings = infoUsecase.getSeniorMentorings(status, authDetails); + return ResponseDto.create(MENTORING_FIND.getCode(), GET_MENTORING_LIST_INFO.getMessage(), seniorMentorings); + } } From 1a4f6f1836d9b5079902a2604fedba1a5f308080 Mon Sep 17 00:00:00 2001 From: ay-eonii Date: Mon, 6 Nov 2023 13:24:32 +0900 Subject: [PATCH 04/24] =?UTF-8?q?RAC-103=20feat:=20=EB=8C=80=ED=95=99?= =?UTF-8?q?=EC=9B=90=EC=83=9D=20=EB=A9=98=ED=86=A0=EB=A7=81=20=EB=AA=A9?= =?UTF-8?q?=EB=A1=9D=20=EC=A1=B0=ED=9A=8C=20response=EC=97=90=20mentoringI?= =?UTF-8?q?d=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mentoring/application/dto/res/SeniorMentoringResponse.java | 1 + .../domain/mentoring/application/mapper/MentoringMapper.java | 1 + 2 files changed, 2 insertions(+) diff --git a/src/main/java/com/postgraduate/domain/mentoring/application/dto/res/SeniorMentoringResponse.java b/src/main/java/com/postgraduate/domain/mentoring/application/dto/res/SeniorMentoringResponse.java index b06134dd..cf79f7d1 100644 --- a/src/main/java/com/postgraduate/domain/mentoring/application/dto/res/SeniorMentoringResponse.java +++ b/src/main/java/com/postgraduate/domain/mentoring/application/dto/res/SeniorMentoringResponse.java @@ -8,6 +8,7 @@ @AllArgsConstructor @Getter public class SeniorMentoringResponse { + private Long mentoringId; private String nickname; private String[] dates; private int term; diff --git a/src/main/java/com/postgraduate/domain/mentoring/application/mapper/MentoringMapper.java b/src/main/java/com/postgraduate/domain/mentoring/application/mapper/MentoringMapper.java index 2a1bf754..645b661c 100644 --- a/src/main/java/com/postgraduate/domain/mentoring/application/mapper/MentoringMapper.java +++ b/src/main/java/com/postgraduate/domain/mentoring/application/mapper/MentoringMapper.java @@ -68,6 +68,7 @@ public static Mentoring mapToMentoring(User user, Senior senior, MentoringApplyR public static SeniorMentoringResponse mapToSeniorMentoring(Mentoring mentoring) { String[] dates = mentoring.getDate().split(","); return SeniorMentoringResponse.builder() + .mentoringId(mentoring.getMentoringId()) .nickname(mentoring.getUser().getNickName()) .dates(dates) .term(mentoring.getSenior().getTerm()) From 8fb7a656a43240b6092e8011ecfbf48b107ede53 Mon Sep 17 00:00:00 2001 From: ay-eonii Date: Mon, 6 Nov 2023 13:43:19 +0900 Subject: [PATCH 05/24] =?UTF-8?q?RAC-103=20feat:=20=EB=8C=80=ED=95=99?= =?UTF-8?q?=EC=9B=90=EC=83=9D=20=EB=A9=98=ED=86=A0=EB=A7=81=20=EC=83=81?= =?UTF-8?q?=EC=84=B8=20response=20=EB=B0=8F=20=EB=A7=A4=ED=8D=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/res/SeniorMentoringDetailResponse.java | 15 +++++++++++++++ .../application/mapper/MentoringMapper.java | 11 +++++++++++ 2 files changed, 26 insertions(+) create mode 100644 src/main/java/com/postgraduate/domain/mentoring/application/dto/res/SeniorMentoringDetailResponse.java diff --git a/src/main/java/com/postgraduate/domain/mentoring/application/dto/res/SeniorMentoringDetailResponse.java b/src/main/java/com/postgraduate/domain/mentoring/application/dto/res/SeniorMentoringDetailResponse.java new file mode 100644 index 00000000..26297d93 --- /dev/null +++ b/src/main/java/com/postgraduate/domain/mentoring/application/dto/res/SeniorMentoringDetailResponse.java @@ -0,0 +1,15 @@ +package com.postgraduate.domain.mentoring.application.dto.res; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; + +@Builder +@AllArgsConstructor +@Getter +public class SeniorMentoringDetailResponse { + private String nickName; + private String topic; + private String question; + private String[] dates; +} diff --git a/src/main/java/com/postgraduate/domain/mentoring/application/mapper/MentoringMapper.java b/src/main/java/com/postgraduate/domain/mentoring/application/mapper/MentoringMapper.java index 645b661c..9d5c6778 100644 --- a/src/main/java/com/postgraduate/domain/mentoring/application/mapper/MentoringMapper.java +++ b/src/main/java/com/postgraduate/domain/mentoring/application/mapper/MentoringMapper.java @@ -3,6 +3,7 @@ import com.postgraduate.domain.mentoring.application.dto.AppliedMentoringInfo; import com.postgraduate.domain.mentoring.application.dto.req.MentoringApplyRequest; import com.postgraduate.domain.mentoring.application.dto.res.AppliedMentoringDetailResponse; +import com.postgraduate.domain.mentoring.application.dto.res.SeniorMentoringDetailResponse; import com.postgraduate.domain.mentoring.application.dto.res.SeniorMentoringResponse; import com.postgraduate.domain.mentoring.domain.entity.Mentoring; import com.postgraduate.domain.senior.domain.entity.Senior; @@ -74,4 +75,14 @@ public static SeniorMentoringResponse mapToSeniorMentoring(Mentoring mentoring) .term(mentoring.getSenior().getTerm()) .build(); } + + public static SeniorMentoringDetailResponse mapToSeniorMentoringDetail(Mentoring mentoring) { + String[] dates = mentoring.getDate().split(","); + return SeniorMentoringDetailResponse.builder() + .nickName(mentoring.getUser().getNickName()) + .topic(mentoring.getTopic()) + .question(mentoring.getQuestion()) + .dates(dates) + .build(); + } } From 73337f83de3ddd48b6b32444c61be8a70cc77d9e Mon Sep 17 00:00:00 2001 From: ay-eonii Date: Mon, 6 Nov 2023 13:44:56 +0900 Subject: [PATCH 06/24] =?UTF-8?q?RAC-103=20feat:=20=EB=8C=80=ED=95=99?= =?UTF-8?q?=EC=9B=90=EC=83=9D=20=EB=A9=98=ED=86=A0=EB=A7=81=20=EC=83=81?= =?UTF-8?q?=EC=84=B8=20=EC=A1=B0=ED=9A=8C=20=EC=96=B4=ED=94=8C=EB=A6=AC?= =?UTF-8?q?=EC=BC=80=EC=9D=B4=EC=85=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../application/usecase/MentoringInfoUseCase.java | 8 ++++++++ .../mentoring/presentation/MentoringController.java | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/src/main/java/com/postgraduate/domain/mentoring/application/usecase/MentoringInfoUseCase.java b/src/main/java/com/postgraduate/domain/mentoring/application/usecase/MentoringInfoUseCase.java index e1cc93d4..4345f231 100644 --- a/src/main/java/com/postgraduate/domain/mentoring/application/usecase/MentoringInfoUseCase.java +++ b/src/main/java/com/postgraduate/domain/mentoring/application/usecase/MentoringInfoUseCase.java @@ -3,6 +3,7 @@ import com.postgraduate.domain.mentoring.application.dto.res.AppliedMentoringDetailResponse; import com.postgraduate.domain.mentoring.application.dto.res.AppliedMentoringResponse; import com.postgraduate.domain.mentoring.application.dto.AppliedMentoringInfo; +import com.postgraduate.domain.mentoring.application.dto.res.SeniorMentoringDetailResponse; import com.postgraduate.domain.mentoring.application.dto.res.SeniorMentoringResponse; import com.postgraduate.domain.mentoring.application.mapper.MentoringMapper; import com.postgraduate.domain.mentoring.domain.entity.Mentoring; @@ -74,4 +75,11 @@ public AppliedMentoringDetailResponse getMentoringDetail(AuthDetails authDetails Mentoring mentoring = checkIsMyMentoringUseCase.checkByRole(user, mentoringId); return MentoringMapper.mapToAppliedDetailInfo(mentoring); } + + public SeniorMentoringDetailResponse getSeniorMentoringDetail(AuthDetails authDetails, Long mentoringId) { + User user = securityUtils.getLoggedInUser(authDetails); + Senior senior = seniorGetService.byUser(user); + Mentoring mentoring = checkIsMyMentoringUseCase.checkByRole(senior, mentoringId); + return MentoringMapper.mapToSeniorMentoringDetail(mentoring); + } } diff --git a/src/main/java/com/postgraduate/domain/mentoring/presentation/MentoringController.java b/src/main/java/com/postgraduate/domain/mentoring/presentation/MentoringController.java index 09807cd8..8ffbb1ff 100644 --- a/src/main/java/com/postgraduate/domain/mentoring/presentation/MentoringController.java +++ b/src/main/java/com/postgraduate/domain/mentoring/presentation/MentoringController.java @@ -4,6 +4,7 @@ import com.postgraduate.domain.mentoring.application.dto.req.MentoringStatusRequest; import com.postgraduate.domain.mentoring.application.dto.res.AppliedMentoringDetailResponse; import com.postgraduate.domain.mentoring.application.dto.res.AppliedMentoringResponse; +import com.postgraduate.domain.mentoring.application.dto.res.SeniorMentoringDetailResponse; import com.postgraduate.domain.mentoring.application.dto.res.SeniorMentoringResponse; import com.postgraduate.domain.mentoring.application.usecase.MentoringApplyUseCase; import com.postgraduate.domain.mentoring.application.usecase.MentoringInfoUseCase; @@ -67,4 +68,11 @@ public ResponseDto> getSeniorMentorings(@RequestPa List seniorMentorings = infoUsecase.getSeniorMentorings(status, authDetails); return ResponseDto.create(MENTORING_FIND.getCode(), GET_MENTORING_LIST_INFO.getMessage(), seniorMentorings); } + + @GetMapping("/senior/me/{mentoringId}") + @Operation(summary = "[대학원생] 신청받은 멘토링 상세조회", description = "대학원생이 신청받은 멘토링을 상세조회합니다.") + public ResponseDto getSeniorMentoringDetail(@AuthenticationPrincipal AuthDetails authDetails, @PathVariable Long mentoringId) { + SeniorMentoringDetailResponse seniorMentoringDetail = infoUsecase.getSeniorMentoringDetail(authDetails, mentoringId); + return ResponseDto.create(MENTORING_FIND.getCode(), GET_MENTORING_DETAIL_INFO.getMessage(), seniorMentoringDetail); + } } From a2a6f02b8c92d2b0ca95ada3412dc5e56e95ce57 Mon Sep 17 00:00:00 2001 From: ay-eonii Date: Mon, 6 Nov 2023 13:47:31 +0900 Subject: [PATCH 07/24] =?UTF-8?q?RAC-103=20refactor:=20=EB=A9=98=ED=86=A0?= =?UTF-8?q?=EB=A7=81=20=EB=A7=A4=ED=8D=BC=20=EB=A9=94=EC=84=9C=EB=93=9C=20?= =?UTF-8?q?=EC=B0=B8=EC=A1=B0=20=ED=91=9C=ED=98=84=EC=8B=9D=20=EC=82=AC?= =?UTF-8?q?=EC=9A=A9=ED=95=98=EB=8F=84=EB=A1=9D=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mentoring/application/usecase/MentoringInfoUseCase.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/com/postgraduate/domain/mentoring/application/usecase/MentoringInfoUseCase.java b/src/main/java/com/postgraduate/domain/mentoring/application/usecase/MentoringInfoUseCase.java index 4345f231..5873fa47 100644 --- a/src/main/java/com/postgraduate/domain/mentoring/application/usecase/MentoringInfoUseCase.java +++ b/src/main/java/com/postgraduate/domain/mentoring/application/usecase/MentoringInfoUseCase.java @@ -46,8 +46,7 @@ public List getSeniorMentorings(Status status, AuthDeta Senior senior = seniorGetService.byUser(user); List mentorings = mentoringGetService.mentoringBySenior(senior, status); - return mentorings.stream().map(mentoring -> - MentoringMapper.mapToSeniorMentoring(mentoring)).collect(Collectors.toList()); + return mentorings.stream().map(MentoringMapper::mapToSeniorMentoring).collect(Collectors.toList()); } private AppliedMentoringResponse getCategories(Status status, List mentorings) { From b8e9c9ce6e54ac95195433ba5c91aa295b98e410 Mon Sep 17 00:00:00 2001 From: ay-eonii Date: Mon, 6 Nov 2023 14:02:52 +0900 Subject: [PATCH 08/24] =?UTF-8?q?RAC-103=20feat:=20=EC=99=84=EB=A3=8C?= =?UTF-8?q?=EB=90=9C=20=EB=A9=98=ED=86=A0=EB=A7=81=20=EC=98=88=EC=99=B8=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 --- .../mentoring/exception/MentoringDoneException.java | 12 ++++++++++++ .../presentation/constant/MentoringResponseCode.java | 3 ++- .../constant/MentoringResponseMessage.java | 3 ++- 3 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 src/main/java/com/postgraduate/domain/mentoring/exception/MentoringDoneException.java diff --git a/src/main/java/com/postgraduate/domain/mentoring/exception/MentoringDoneException.java b/src/main/java/com/postgraduate/domain/mentoring/exception/MentoringDoneException.java new file mode 100644 index 00000000..6da8c5c6 --- /dev/null +++ b/src/main/java/com/postgraduate/domain/mentoring/exception/MentoringDoneException.java @@ -0,0 +1,12 @@ +package com.postgraduate.domain.mentoring.exception; + +import static com.postgraduate.domain.mentoring.presentation.constant.MentoringResponseCode.MENTORING_DONE; +import static com.postgraduate.domain.mentoring.presentation.constant.MentoringResponseMessage.DONE_MENTORING; + + +public class MentoringDoneException extends MentoringException { + + public MentoringDoneException() { + super(DONE_MENTORING.getMessage(), MENTORING_DONE.getCode()); + } +} diff --git a/src/main/java/com/postgraduate/domain/mentoring/presentation/constant/MentoringResponseCode.java b/src/main/java/com/postgraduate/domain/mentoring/presentation/constant/MentoringResponseCode.java index 87f176d7..1e7db3a1 100644 --- a/src/main/java/com/postgraduate/domain/mentoring/presentation/constant/MentoringResponseCode.java +++ b/src/main/java/com/postgraduate/domain/mentoring/presentation/constant/MentoringResponseCode.java @@ -11,7 +11,8 @@ public enum MentoringResponseCode { MENTORING_CREATE("MT202"), MENTORING_DELETE("MT203"), - MENTORING_NOT_FOUND("MT400") + MENTORING_NOT_FOUND("EX901"), + MENTORING_DONE("EX902"), ; private final String code; } \ No newline at end of file diff --git a/src/main/java/com/postgraduate/domain/mentoring/presentation/constant/MentoringResponseMessage.java b/src/main/java/com/postgraduate/domain/mentoring/presentation/constant/MentoringResponseMessage.java index 034b83ff..90f22671 100644 --- a/src/main/java/com/postgraduate/domain/mentoring/presentation/constant/MentoringResponseMessage.java +++ b/src/main/java/com/postgraduate/domain/mentoring/presentation/constant/MentoringResponseMessage.java @@ -11,7 +11,8 @@ public enum MentoringResponseMessage { CREATE_MENTORING("멘토링 신청에 성공하였습니다."), UPDATE_MENTORING("멘토링 상태 갱신에 성공하였습니다."), - NOT_FOUND_MENTORING("멘토링이 존재하지 않습니다."); + NOT_FOUND_MENTORING("멘토링이 존재하지 않습니다."), + DONE_MENTORING("완료된 멘토링입니다."); private final String message; } From 0eef2464e3abbc33d68069438d2a9883ec7e4a90 Mon Sep 17 00:00:00 2001 From: ay-eonii Date: Mon, 6 Nov 2023 14:03:12 +0900 Subject: [PATCH 09/24] =?UTF-8?q?RAC-103=20feat:=20=EC=99=84=EB=A3=8C?= =?UTF-8?q?=EB=90=9C=20=EB=A9=98=ED=86=A0=EB=A7=81=20=EC=83=81=EC=84=B8=20?= =?UTF-8?q?=EC=A1=B0=ED=9A=8C=20=EC=8B=9C=20=EC=98=88=EC=99=B8=20=EB=B0=9C?= =?UTF-8?q?=EC=83=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../application/usecase/MentoringInfoUseCase.java | 8 +++++++- .../mentoring/presentation/MentoringController.java | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/postgraduate/domain/mentoring/application/usecase/MentoringInfoUseCase.java b/src/main/java/com/postgraduate/domain/mentoring/application/usecase/MentoringInfoUseCase.java index 5873fa47..21b13abb 100644 --- a/src/main/java/com/postgraduate/domain/mentoring/application/usecase/MentoringInfoUseCase.java +++ b/src/main/java/com/postgraduate/domain/mentoring/application/usecase/MentoringInfoUseCase.java @@ -1,14 +1,15 @@ package com.postgraduate.domain.mentoring.application.usecase; +import com.postgraduate.domain.mentoring.application.dto.AppliedMentoringInfo; import com.postgraduate.domain.mentoring.application.dto.res.AppliedMentoringDetailResponse; import com.postgraduate.domain.mentoring.application.dto.res.AppliedMentoringResponse; -import com.postgraduate.domain.mentoring.application.dto.AppliedMentoringInfo; import com.postgraduate.domain.mentoring.application.dto.res.SeniorMentoringDetailResponse; import com.postgraduate.domain.mentoring.application.dto.res.SeniorMentoringResponse; import com.postgraduate.domain.mentoring.application.mapper.MentoringMapper; import com.postgraduate.domain.mentoring.domain.entity.Mentoring; import com.postgraduate.domain.mentoring.domain.entity.constant.Status; import com.postgraduate.domain.mentoring.domain.service.MentoringGetService; +import com.postgraduate.domain.mentoring.exception.MentoringDoneException; import com.postgraduate.domain.senior.domain.entity.Senior; import com.postgraduate.domain.senior.domain.service.SeniorGetService; import com.postgraduate.domain.user.domain.entity.User; @@ -22,6 +23,8 @@ import java.util.List; import java.util.stream.Collectors; +import static com.postgraduate.domain.mentoring.domain.entity.constant.Status.DONE; + @Service @Transactional @RequiredArgsConstructor @@ -79,6 +82,9 @@ public SeniorMentoringDetailResponse getSeniorMentoringDetail(AuthDetails authDe User user = securityUtils.getLoggedInUser(authDetails); Senior senior = seniorGetService.byUser(user); Mentoring mentoring = checkIsMyMentoringUseCase.checkByRole(senior, mentoringId); + if (mentoring.getStatus() == DONE) { + throw new MentoringDoneException(); + } return MentoringMapper.mapToSeniorMentoringDetail(mentoring); } } diff --git a/src/main/java/com/postgraduate/domain/mentoring/presentation/MentoringController.java b/src/main/java/com/postgraduate/domain/mentoring/presentation/MentoringController.java index 8ffbb1ff..c5eea5a5 100644 --- a/src/main/java/com/postgraduate/domain/mentoring/presentation/MentoringController.java +++ b/src/main/java/com/postgraduate/domain/mentoring/presentation/MentoringController.java @@ -70,7 +70,7 @@ public ResponseDto> getSeniorMentorings(@RequestPa } @GetMapping("/senior/me/{mentoringId}") - @Operation(summary = "[대학원생] 신청받은 멘토링 상세조회", description = "대학원생이 신청받은 멘토링을 상세조회합니다.") + @Operation(summary = "[대학원생] 신청받은 멘토링 상세조회", description = "대학원생이 신청받은 멘토링을 상세조회합니다. <완료> 상태의 멘토링은 상세조회되지 않습니다.") public ResponseDto getSeniorMentoringDetail(@AuthenticationPrincipal AuthDetails authDetails, @PathVariable Long mentoringId) { SeniorMentoringDetailResponse seniorMentoringDetail = infoUsecase.getSeniorMentoringDetail(authDetails, mentoringId); return ResponseDto.create(MENTORING_FIND.getCode(), GET_MENTORING_DETAIL_INFO.getMessage(), seniorMentoringDetail); From e47afbc34292ebedb6031fc4b8230bbf351fe05d Mon Sep 17 00:00:00 2001 From: ay-eonii Date: Mon, 6 Nov 2023 14:23:58 +0900 Subject: [PATCH 10/24] =?UTF-8?q?RAC-103=20feat:=20=EB=A9=98=ED=86=A0?= =?UTF-8?q?=EB=A7=81=20=EC=8B=9C=EA=B0=84=20=EC=84=A0=ED=83=9D=20request?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../application/dto/req/MentoringDateRequest.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 src/main/java/com/postgraduate/domain/mentoring/application/dto/req/MentoringDateRequest.java diff --git a/src/main/java/com/postgraduate/domain/mentoring/application/dto/req/MentoringDateRequest.java b/src/main/java/com/postgraduate/domain/mentoring/application/dto/req/MentoringDateRequest.java new file mode 100644 index 00000000..ae67820c --- /dev/null +++ b/src/main/java/com/postgraduate/domain/mentoring/application/dto/req/MentoringDateRequest.java @@ -0,0 +1,14 @@ +package com.postgraduate.domain.mentoring.application.dto.req; + +import jakarta.validation.constraints.NotNull; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Getter +@NoArgsConstructor +@AllArgsConstructor +public class MentoringDateRequest { + @NotNull + private String date; +} From eab988cddf49bf5d9e5d69906e4284f04e1238bb Mon Sep 17 00:00:00 2001 From: ay-eonii Date: Mon, 6 Nov 2023 14:24:14 +0900 Subject: [PATCH 11/24] =?UTF-8?q?RAC-103=20feat:=20=EB=A9=98=ED=86=A0?= =?UTF-8?q?=EB=A7=81=20=EC=8B=9C=EA=B0=84=20=EC=84=A0=ED=83=9D=20=EC=84=9C?= =?UTF-8?q?=EB=B9=84=EC=8A=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/mentoring/domain/entity/Mentoring.java | 4 ++++ .../mentoring/domain/service/MentoringUpdateService.java | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/src/main/java/com/postgraduate/domain/mentoring/domain/entity/Mentoring.java b/src/main/java/com/postgraduate/domain/mentoring/domain/entity/Mentoring.java index 28a795f6..2438e0b2 100644 --- a/src/main/java/com/postgraduate/domain/mentoring/domain/entity/Mentoring.java +++ b/src/main/java/com/postgraduate/domain/mentoring/domain/entity/Mentoring.java @@ -58,4 +58,8 @@ public void updateStatus(Status status) { public void updateDeletedAt() { this.deletedAt = LocalDate.now(); } + + public void updateDate(String date) { + this.date = date; + } } diff --git a/src/main/java/com/postgraduate/domain/mentoring/domain/service/MentoringUpdateService.java b/src/main/java/com/postgraduate/domain/mentoring/domain/service/MentoringUpdateService.java index 2574b069..7742296f 100644 --- a/src/main/java/com/postgraduate/domain/mentoring/domain/service/MentoringUpdateService.java +++ b/src/main/java/com/postgraduate/domain/mentoring/domain/service/MentoringUpdateService.java @@ -15,4 +15,8 @@ public void updateStatus(Mentoring mentoring, Status status) { } mentoring.updateStatus(status); } + + public void updateDate(Mentoring mentoring, String date) { + mentoring.updateDate(date); + } } From bcd5e4645b9e1e65af33693d2de1727930b11c9e Mon Sep 17 00:00:00 2001 From: ay-eonii Date: Mon, 6 Nov 2023 14:25:27 +0900 Subject: [PATCH 12/24] =?UTF-8?q?RAC-103=20feat:=20=ED=99=95=EC=A0=95=20?= =?UTF-8?q?=EB=8C=80=EA=B8=B0=20=EC=83=81=ED=83=9C=20=EB=A9=98=ED=86=A0?= =?UTF-8?q?=EB=A7=81=20=EC=95=84=EB=8B=90=20=EA=B2=BD=EC=9A=B0=20=EC=98=88?= =?UTF-8?q?=EC=99=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../exception/MentoringNotWaitingException.java | 12 ++++++++++++ .../presentation/constant/MentoringResponseCode.java | 1 + .../constant/MentoringResponseMessage.java | 4 +++- 3 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/postgraduate/domain/mentoring/exception/MentoringNotWaitingException.java diff --git a/src/main/java/com/postgraduate/domain/mentoring/exception/MentoringNotWaitingException.java b/src/main/java/com/postgraduate/domain/mentoring/exception/MentoringNotWaitingException.java new file mode 100644 index 00000000..b7626f58 --- /dev/null +++ b/src/main/java/com/postgraduate/domain/mentoring/exception/MentoringNotWaitingException.java @@ -0,0 +1,12 @@ +package com.postgraduate.domain.mentoring.exception; + +import static com.postgraduate.domain.mentoring.presentation.constant.MentoringResponseCode.MENTORING_NOT_WAITING; +import static com.postgraduate.domain.mentoring.presentation.constant.MentoringResponseMessage.NOT_WAITING_MENTORING; + + +public class MentoringNotWaitingException extends MentoringException { + + public MentoringNotWaitingException() { + super(NOT_WAITING_MENTORING.getMessage(), MENTORING_NOT_WAITING.getCode()); + } +} diff --git a/src/main/java/com/postgraduate/domain/mentoring/presentation/constant/MentoringResponseCode.java b/src/main/java/com/postgraduate/domain/mentoring/presentation/constant/MentoringResponseCode.java index 1e7db3a1..895ca3e0 100644 --- a/src/main/java/com/postgraduate/domain/mentoring/presentation/constant/MentoringResponseCode.java +++ b/src/main/java/com/postgraduate/domain/mentoring/presentation/constant/MentoringResponseCode.java @@ -13,6 +13,7 @@ public enum MentoringResponseCode { MENTORING_NOT_FOUND("EX901"), MENTORING_DONE("EX902"), + MENTORING_NOT_WAITING("EX903"), ; private final String code; } \ No newline at end of file diff --git a/src/main/java/com/postgraduate/domain/mentoring/presentation/constant/MentoringResponseMessage.java b/src/main/java/com/postgraduate/domain/mentoring/presentation/constant/MentoringResponseMessage.java index 90f22671..e53bcbbc 100644 --- a/src/main/java/com/postgraduate/domain/mentoring/presentation/constant/MentoringResponseMessage.java +++ b/src/main/java/com/postgraduate/domain/mentoring/presentation/constant/MentoringResponseMessage.java @@ -12,7 +12,9 @@ public enum MentoringResponseMessage { UPDATE_MENTORING("멘토링 상태 갱신에 성공하였습니다."), NOT_FOUND_MENTORING("멘토링이 존재하지 않습니다."), - DONE_MENTORING("완료된 멘토링입니다."); + DONE_MENTORING("완료된 멘토링입니다."), + NOT_WAITING_MENTORING("확정 대기 상태의 멘토링이 아닙니다."), + ; private final String message; } From 012e08c758f128289dd19d48bd0f024cf6105782 Mon Sep 17 00:00:00 2001 From: ay-eonii Date: Mon, 6 Nov 2023 14:25:52 +0900 Subject: [PATCH 13/24] =?UTF-8?q?RAC-103=20feat:=20=EB=A9=98=ED=86=A0?= =?UTF-8?q?=EB=A7=81=20=EC=8B=9C=EA=B0=84=20=EC=84=A0=ED=83=9D=20=EC=96=B4?= =?UTF-8?q?=ED=94=8C=EB=A6=AC=EC=BC=80=EC=9D=B4=EC=85=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../usecase/MentoringManageUseCase.java | 17 +++++++++++++++++ .../presentation/MentoringController.java | 14 ++++++++++++-- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/postgraduate/domain/mentoring/application/usecase/MentoringManageUseCase.java b/src/main/java/com/postgraduate/domain/mentoring/application/usecase/MentoringManageUseCase.java index ac2383ec..2b51ea20 100644 --- a/src/main/java/com/postgraduate/domain/mentoring/application/usecase/MentoringManageUseCase.java +++ b/src/main/java/com/postgraduate/domain/mentoring/application/usecase/MentoringManageUseCase.java @@ -1,8 +1,12 @@ package com.postgraduate.domain.mentoring.application.usecase; +import com.postgraduate.domain.mentoring.application.dto.req.MentoringDateRequest; import com.postgraduate.domain.mentoring.application.dto.req.MentoringStatusRequest; import com.postgraduate.domain.mentoring.domain.entity.Mentoring; import com.postgraduate.domain.mentoring.domain.service.MentoringUpdateService; +import com.postgraduate.domain.mentoring.exception.MentoringNotWaitingException; +import com.postgraduate.domain.senior.domain.entity.Senior; +import com.postgraduate.domain.senior.domain.service.SeniorGetService; import com.postgraduate.domain.user.domain.entity.User; import com.postgraduate.global.auth.AuthDetails; import com.postgraduate.global.config.security.util.SecurityUtils; @@ -10,12 +14,15 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import static com.postgraduate.domain.mentoring.domain.entity.constant.Status.WAITING; + @Service @Transactional @RequiredArgsConstructor public class MentoringManageUseCase { private final SecurityUtils securityUtils; private final MentoringUpdateService mentoringUpdateService; + private final SeniorGetService seniorGetService; private final CheckIsMyMentoringUseCase checkIsMyMentoringUseCase; public void updateStatus(AuthDetails authDetails, Long mentoringId, MentoringStatusRequest request) { @@ -23,4 +30,14 @@ public void updateStatus(AuthDetails authDetails, Long mentoringId, MentoringSta Mentoring mentoring = checkIsMyMentoringUseCase.checkByRole(user, mentoringId); mentoringUpdateService.updateStatus(mentoring, request.getStatus()); } + + public void updateDate(AuthDetails authDetails, Long mentoringId, MentoringDateRequest request) { + User user = securityUtils.getLoggedInUser(authDetails); + Senior senior = seniorGetService.byUser(user); + Mentoring mentoring = checkIsMyMentoringUseCase.checkByRole(senior, mentoringId); + if (mentoring.getStatus() != WAITING) { + throw new MentoringNotWaitingException(); + } + mentoringUpdateService.updateDate(mentoring, request.getDate()); + } } diff --git a/src/main/java/com/postgraduate/domain/mentoring/presentation/MentoringController.java b/src/main/java/com/postgraduate/domain/mentoring/presentation/MentoringController.java index c5eea5a5..2726ebbd 100644 --- a/src/main/java/com/postgraduate/domain/mentoring/presentation/MentoringController.java +++ b/src/main/java/com/postgraduate/domain/mentoring/presentation/MentoringController.java @@ -1,6 +1,7 @@ package com.postgraduate.domain.mentoring.presentation; import com.postgraduate.domain.mentoring.application.dto.req.MentoringApplyRequest; +import com.postgraduate.domain.mentoring.application.dto.req.MentoringDateRequest; import com.postgraduate.domain.mentoring.application.dto.req.MentoringStatusRequest; import com.postgraduate.domain.mentoring.application.dto.res.AppliedMentoringDetailResponse; import com.postgraduate.domain.mentoring.application.dto.res.AppliedMentoringResponse; @@ -30,7 +31,7 @@ public class MentoringController { private final MentoringInfoUseCase infoUsecase; private final MentoringApplyUseCase applyUseCase; - private final MentoringManageUseCase updateUseCase; + private final MentoringManageUseCase manageUseCase; @GetMapping("/me") @Operation(summary = "[대학생] 신청한 멘토링 목록 조회", description = "대학생이 신청한 멘토링 목록을 조회합니다.") @@ -58,7 +59,7 @@ public ResponseDto applyMentoring(@AuthenticationPrincipal AuthDetails authDetai public ResponseDto updateMentoringStatus(@AuthenticationPrincipal AuthDetails authDetails, @PathVariable Long mentoringId, @RequestBody MentoringStatusRequest request) { - updateUseCase.updateStatus(authDetails, mentoringId, request); + manageUseCase.updateStatus(authDetails, mentoringId, request); return ResponseDto.create(MENTORING_UPDATE.getCode(), UPDATE_MENTORING.getMessage()); } @@ -75,4 +76,13 @@ public ResponseDto getSeniorMentoringDetail(@Auth SeniorMentoringDetailResponse seniorMentoringDetail = infoUsecase.getSeniorMentoringDetail(authDetails, mentoringId); return ResponseDto.create(MENTORING_FIND.getCode(), GET_MENTORING_DETAIL_INFO.getMessage(), seniorMentoringDetail); } + + @PatchMapping("/senior/me/{mentoringId}") + @Operation(summary = "[대학원생] 멘토링 시간 선택", description = "대학생이 신청한 시간 옵션 3개 중 하나를 선택합니다. 확정 대기 상태의 멘토링만 가능합니다.") + public ResponseDto getSeniorMentorings(@AuthenticationPrincipal AuthDetails authDetails, + @PathVariable Long mentoringId, + @RequestBody MentoringDateRequest request) { + manageUseCase.updateDate(authDetails, mentoringId, request); + return ResponseDto.create(MENTORING_UPDATE.getCode(), UPDATE_MENTORING.getMessage()); + } } From 4e1489f577d0f54796ff49bfd29f29ab15a47407 Mon Sep 17 00:00:00 2001 From: ay-eonii Date: Mon, 6 Nov 2023 18:14:50 +0900 Subject: [PATCH 14/24] =?UTF-8?q?RAC-103=20feat:=20=EB=8C=80=ED=95=99?= =?UTF-8?q?=EC=9B=90=EC=83=9D=20=EB=A9=98=ED=86=A0=EB=A7=81=20=EC=83=81?= =?UTF-8?q?=ED=83=9C=EB=B3=80=EA=B2=BD=20=EC=96=B4=ED=94=8C=EB=A6=AC?= =?UTF-8?q?=EC=BC=80=EC=9D=B4=EC=85=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../usecase/MentoringManageUseCase.java | 7 +++++++ .../presentation/MentoringController.java | 17 ++++++++++++++--- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/postgraduate/domain/mentoring/application/usecase/MentoringManageUseCase.java b/src/main/java/com/postgraduate/domain/mentoring/application/usecase/MentoringManageUseCase.java index 2b51ea20..ab76d0b0 100644 --- a/src/main/java/com/postgraduate/domain/mentoring/application/usecase/MentoringManageUseCase.java +++ b/src/main/java/com/postgraduate/domain/mentoring/application/usecase/MentoringManageUseCase.java @@ -31,6 +31,13 @@ public void updateStatus(AuthDetails authDetails, Long mentoringId, MentoringSta mentoringUpdateService.updateStatus(mentoring, request.getStatus()); } + public void updateSeniorStatus(AuthDetails authDetails, Long mentoringId, MentoringStatusRequest request) { + User user = securityUtils.getLoggedInUser(authDetails); + Senior senior = seniorGetService.byUser(user); + Mentoring mentoring = checkIsMyMentoringUseCase.checkByRole(senior, mentoringId); + mentoringUpdateService.updateStatus(mentoring, request.getStatus()); + } + public void updateDate(AuthDetails authDetails, Long mentoringId, MentoringDateRequest request) { User user = securityUtils.getLoggedInUser(authDetails); Senior senior = seniorGetService.byUser(user); diff --git a/src/main/java/com/postgraduate/domain/mentoring/presentation/MentoringController.java b/src/main/java/com/postgraduate/domain/mentoring/presentation/MentoringController.java index 2726ebbd..203436e5 100644 --- a/src/main/java/com/postgraduate/domain/mentoring/presentation/MentoringController.java +++ b/src/main/java/com/postgraduate/domain/mentoring/presentation/MentoringController.java @@ -2,6 +2,7 @@ import com.postgraduate.domain.mentoring.application.dto.req.MentoringApplyRequest; import com.postgraduate.domain.mentoring.application.dto.req.MentoringDateRequest; +import com.postgraduate.domain.mentoring.application.dto.req.MentoringRefuseRequest; import com.postgraduate.domain.mentoring.application.dto.req.MentoringStatusRequest; import com.postgraduate.domain.mentoring.application.dto.res.AppliedMentoringDetailResponse; import com.postgraduate.domain.mentoring.application.dto.res.AppliedMentoringResponse; @@ -77,12 +78,22 @@ public ResponseDto getSeniorMentoringDetail(@Auth return ResponseDto.create(MENTORING_FIND.getCode(), GET_MENTORING_DETAIL_INFO.getMessage(), seniorMentoringDetail); } - @PatchMapping("/senior/me/{mentoringId}") + @PatchMapping("/senior/me/{mentoringId}/time") @Operation(summary = "[대학원생] 멘토링 시간 선택", description = "대학생이 신청한 시간 옵션 3개 중 하나를 선택합니다. 확정 대기 상태의 멘토링만 가능합니다.") public ResponseDto getSeniorMentorings(@AuthenticationPrincipal AuthDetails authDetails, - @PathVariable Long mentoringId, - @RequestBody MentoringDateRequest request) { + @PathVariable Long mentoringId, + @RequestBody MentoringDateRequest request) { manageUseCase.updateDate(authDetails, mentoringId, request); return ResponseDto.create(MENTORING_UPDATE.getCode(), UPDATE_MENTORING.getMessage()); } + + @PatchMapping("/senior/me/{mentoringId}") + @Operation(summary = "[대학원생] 멘토링 상태 업데이트", description = "대학원생이 멘토링 상태를 변경합니다.") + public ResponseDto updateSeniorMentoringStatus(@AuthenticationPrincipal AuthDetails authDetails, + @PathVariable Long mentoringId, + @RequestBody MentoringStatusRequest request) { + manageUseCase.updateSeniorStatus(authDetails, mentoringId, request); + return ResponseDto.create(MENTORING_UPDATE.getCode(), UPDATE_MENTORING.getMessage()); + } + } From 29c511ef1d15bb5e0f3540a309e2836825d4669c Mon Sep 17 00:00:00 2001 From: ay-eonii Date: Mon, 6 Nov 2023 18:15:48 +0900 Subject: [PATCH 15/24] =?UTF-8?q?RAC-103=20feat:=20=EB=A9=98=ED=86=A0?= =?UTF-8?q?=EB=A7=81=20=EA=B1=B0=EC=A0=88=20=EC=82=AC=EC=9C=A0=20=ED=95=84?= =?UTF-8?q?=EB=93=9C=20=EB=B0=8F=20=EC=97=85=EB=8D=B0=EC=9D=B4=ED=8A=B8=20?= =?UTF-8?q?=EC=84=9C=EB=B9=84=EC=8A=A4=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/mentoring/domain/entity/Mentoring.java | 7 ++++++- .../mentoring/domain/service/MentoringUpdateService.java | 4 ++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/postgraduate/domain/mentoring/domain/entity/Mentoring.java b/src/main/java/com/postgraduate/domain/mentoring/domain/entity/Mentoring.java index 2438e0b2..4409fc08 100644 --- a/src/main/java/com/postgraduate/domain/mentoring/domain/entity/Mentoring.java +++ b/src/main/java/com/postgraduate/domain/mentoring/domain/entity/Mentoring.java @@ -8,7 +8,6 @@ import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; -import org.hibernate.annotations.ColumnDefault; import org.hibernate.annotations.CreationTimestamp; import java.time.LocalDate; @@ -42,6 +41,8 @@ public class Mentoring { @Builder.Default private int pay = 20000; + private String refuse; + @Enumerated(EnumType.STRING) @Builder.Default private Status status = Status.WAITING; @@ -55,6 +56,10 @@ public void updateStatus(Status status) { this.status = status; } + public void updateRefuse(String refuse) { + this.refuse = refuse; + } + public void updateDeletedAt() { this.deletedAt = LocalDate.now(); } diff --git a/src/main/java/com/postgraduate/domain/mentoring/domain/service/MentoringUpdateService.java b/src/main/java/com/postgraduate/domain/mentoring/domain/service/MentoringUpdateService.java index 7742296f..5942c986 100644 --- a/src/main/java/com/postgraduate/domain/mentoring/domain/service/MentoringUpdateService.java +++ b/src/main/java/com/postgraduate/domain/mentoring/domain/service/MentoringUpdateService.java @@ -16,6 +16,10 @@ public void updateStatus(Mentoring mentoring, Status status) { mentoring.updateStatus(status); } + public void updateStatus(Mentoring mentoring, String refuse) { + mentoring.updateRefuse(refuse); + } + public void updateDate(Mentoring mentoring, String date) { mentoring.updateDate(date); } From 5a5b19721679cc9a443036be41bde286d652b05d Mon Sep 17 00:00:00 2001 From: ay-eonii Date: Mon, 6 Nov 2023 18:15:58 +0900 Subject: [PATCH 16/24] =?UTF-8?q?RAC-103=20feat:=20=EB=A9=98=ED=86=A0?= =?UTF-8?q?=EB=A7=81=20=EA=B1=B0=EC=A0=88=20=EC=82=AC=EC=9C=A0=20request?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/req/MentoringRefuseRequest.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 src/main/java/com/postgraduate/domain/mentoring/application/dto/req/MentoringRefuseRequest.java diff --git a/src/main/java/com/postgraduate/domain/mentoring/application/dto/req/MentoringRefuseRequest.java b/src/main/java/com/postgraduate/domain/mentoring/application/dto/req/MentoringRefuseRequest.java new file mode 100644 index 00000000..677989b3 --- /dev/null +++ b/src/main/java/com/postgraduate/domain/mentoring/application/dto/req/MentoringRefuseRequest.java @@ -0,0 +1,14 @@ +package com.postgraduate.domain.mentoring.application.dto.req; + +import jakarta.validation.constraints.NotNull; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Getter +@AllArgsConstructor +@NoArgsConstructor +public class MentoringRefuseRequest { + @NotNull + private String refuse; +} From eb05f1f7a2b5ce6752a513745e2ec11c90841362 Mon Sep 17 00:00:00 2001 From: ay-eonii Date: Mon, 6 Nov 2023 18:16:33 +0900 Subject: [PATCH 17/24] =?UTF-8?q?RAC-103=20feat:=20=EB=A9=98=ED=86=A0?= =?UTF-8?q?=EB=A7=81=20=EA=B1=B0=EC=A0=88=20=EC=82=AC=EC=9C=A0=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD=20=EC=96=B4=ED=94=8C=EB=A6=AC=EC=BC=80=EC=9D=B4?= =?UTF-8?q?=EC=85=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../application/usecase/MentoringManageUseCase.java | 8 ++++++++ .../mentoring/presentation/MentoringController.java | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/src/main/java/com/postgraduate/domain/mentoring/application/usecase/MentoringManageUseCase.java b/src/main/java/com/postgraduate/domain/mentoring/application/usecase/MentoringManageUseCase.java index ab76d0b0..f5bc6640 100644 --- a/src/main/java/com/postgraduate/domain/mentoring/application/usecase/MentoringManageUseCase.java +++ b/src/main/java/com/postgraduate/domain/mentoring/application/usecase/MentoringManageUseCase.java @@ -1,6 +1,7 @@ package com.postgraduate.domain.mentoring.application.usecase; import com.postgraduate.domain.mentoring.application.dto.req.MentoringDateRequest; +import com.postgraduate.domain.mentoring.application.dto.req.MentoringRefuseRequest; import com.postgraduate.domain.mentoring.application.dto.req.MentoringStatusRequest; import com.postgraduate.domain.mentoring.domain.entity.Mentoring; import com.postgraduate.domain.mentoring.domain.service.MentoringUpdateService; @@ -38,6 +39,13 @@ public void updateSeniorStatus(AuthDetails authDetails, Long mentoringId, Mentor mentoringUpdateService.updateStatus(mentoring, request.getStatus()); } + public void updateRefuse(AuthDetails authDetails, Long mentoringId, MentoringRefuseRequest request) { + User user = securityUtils.getLoggedInUser(authDetails); + Senior senior = seniorGetService.byUser(user); + Mentoring mentoring = checkIsMyMentoringUseCase.checkByRole(senior, mentoringId); + mentoringUpdateService.updateStatus(mentoring, request.getRefuse()); + } + public void updateDate(AuthDetails authDetails, Long mentoringId, MentoringDateRequest request) { User user = securityUtils.getLoggedInUser(authDetails); Senior senior = seniorGetService.byUser(user); diff --git a/src/main/java/com/postgraduate/domain/mentoring/presentation/MentoringController.java b/src/main/java/com/postgraduate/domain/mentoring/presentation/MentoringController.java index 203436e5..fbb83c35 100644 --- a/src/main/java/com/postgraduate/domain/mentoring/presentation/MentoringController.java +++ b/src/main/java/com/postgraduate/domain/mentoring/presentation/MentoringController.java @@ -96,4 +96,12 @@ public ResponseDto updateSeniorMentoringStatus(@AuthenticationPrincipal AuthDeta return ResponseDto.create(MENTORING_UPDATE.getCode(), UPDATE_MENTORING.getMessage()); } + @PatchMapping("/senior/me/{mentoringId}/refuse") + @Operation(summary = "[대학원생] 멘토링 거절사유 업데이트", description = "대학원생이 거절사유를 변경합니다.") + public ResponseDto updateSeniorMentoringStatus(@AuthenticationPrincipal AuthDetails authDetails, + @PathVariable Long mentoringId, + @RequestBody MentoringRefuseRequest request) { + manageUseCase.updateRefuse(authDetails, mentoringId, request); + return ResponseDto.create(MENTORING_UPDATE.getCode(), UPDATE_MENTORING.getMessage()); + } } From a23fd3e3ea45c8e84b48c3e09e97678be1866028 Mon Sep 17 00:00:00 2001 From: ay-eonii Date: Thu, 9 Nov 2023 12:13:56 +0900 Subject: [PATCH 18/24] =?UTF-8?q?RAC-103=20fix:=20=EC=8B=A0=EC=B2=AD?= =?UTF-8?q?=ED=95=9C=20=EB=A9=98=ED=86=A0=EB=A7=81=20<=ED=99=95=EC=A0=95?= =?UTF-8?q?=EB=8C=80=EA=B8=B0>=20=EC=83=81=ED=83=9C=EC=97=90=EC=84=9C?= =?UTF-8?q?=EB=A7=8C=20=EC=83=81=EC=84=B8=EC=A1=B0=ED=9A=8C=20=EA=B0=80?= =?UTF-8?q?=EB=8A=A5=ED=95=98=EB=8F=84=EB=A1=9D=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mentoring/application/usecase/MentoringInfoUseCase.java | 5 +++++ .../domain/mentoring/presentation/MentoringController.java | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/postgraduate/domain/mentoring/application/usecase/MentoringInfoUseCase.java b/src/main/java/com/postgraduate/domain/mentoring/application/usecase/MentoringInfoUseCase.java index 21b13abb..b14e2237 100644 --- a/src/main/java/com/postgraduate/domain/mentoring/application/usecase/MentoringInfoUseCase.java +++ b/src/main/java/com/postgraduate/domain/mentoring/application/usecase/MentoringInfoUseCase.java @@ -10,6 +10,7 @@ import com.postgraduate.domain.mentoring.domain.entity.constant.Status; import com.postgraduate.domain.mentoring.domain.service.MentoringGetService; import com.postgraduate.domain.mentoring.exception.MentoringDoneException; +import com.postgraduate.domain.mentoring.exception.MentoringNotWaitingException; import com.postgraduate.domain.senior.domain.entity.Senior; import com.postgraduate.domain.senior.domain.service.SeniorGetService; import com.postgraduate.domain.user.domain.entity.User; @@ -24,6 +25,7 @@ import java.util.stream.Collectors; import static com.postgraduate.domain.mentoring.domain.entity.constant.Status.DONE; +import static com.postgraduate.domain.mentoring.domain.entity.constant.Status.WAITING; @Service @Transactional @@ -75,6 +77,9 @@ private AppliedMentoringResponse getCategories(Status status, List me public AppliedMentoringDetailResponse getMentoringDetail(AuthDetails authDetails, Long mentoringId) { User user = securityUtils.getLoggedInUser(authDetails); Mentoring mentoring = checkIsMyMentoringUseCase.checkByRole(user, mentoringId); + if (mentoring.getStatus() != WAITING) { + throw new MentoringNotWaitingException(); + } return MentoringMapper.mapToAppliedDetailInfo(mentoring); } diff --git a/src/main/java/com/postgraduate/domain/mentoring/presentation/MentoringController.java b/src/main/java/com/postgraduate/domain/mentoring/presentation/MentoringController.java index fbb83c35..9f21984e 100644 --- a/src/main/java/com/postgraduate/domain/mentoring/presentation/MentoringController.java +++ b/src/main/java/com/postgraduate/domain/mentoring/presentation/MentoringController.java @@ -42,7 +42,7 @@ public ResponseDto getMentoringInfos(@RequestParam Sta } @GetMapping("/me/{mentoringId}") - @Operation(summary = "[대학생] 신청한 멘토링 상세조회", description = "대학생이 신청한 멘토링을 상세조회합니다.") + @Operation(summary = "[대학생] 신청한 멘토링 상세조회", description = "대학생이 신청한 멘토링을 상세조회합니다. <확정대기> 상태의 멘토링만 조회 가능합니다.") public ResponseDto getMentoringDetail(@AuthenticationPrincipal AuthDetails authDetails, @PathVariable Long mentoringId) { AppliedMentoringDetailResponse mentoringDetail = infoUsecase.getMentoringDetail(authDetails, mentoringId); return ResponseDto.create(MENTORING_FIND.getCode(), GET_MENTORING_DETAIL_INFO.getMessage(), mentoringDetail); From 1c138e459d07220326e0572b1d4149158e418630 Mon Sep 17 00:00:00 2001 From: ay-eonii Date: Thu, 9 Nov 2023 12:19:08 +0900 Subject: [PATCH 19/24] =?UTF-8?q?RAC-103=20fix:=20=EB=A9=98=ED=86=A0?= =?UTF-8?q?=EB=A7=81=EC=83=81=ED=83=9C=20=EB=B3=80=EA=B2=BD=20=EA=B8=B0?= =?UTF-8?q?=EB=8A=A5=20api=20=EB=B6=84=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/req/MentoringStatusRequest.java | 3 +- .../usecase/MentoringManageUseCase.java | 15 ++++---- .../service/MentoringUpdateService.java | 2 +- .../presentation/MentoringController.java | 34 ++++++++----------- 4 files changed, 25 insertions(+), 29 deletions(-) diff --git a/src/main/java/com/postgraduate/domain/mentoring/application/dto/req/MentoringStatusRequest.java b/src/main/java/com/postgraduate/domain/mentoring/application/dto/req/MentoringStatusRequest.java index a2c6e5d3..1b0b7b23 100644 --- a/src/main/java/com/postgraduate/domain/mentoring/application/dto/req/MentoringStatusRequest.java +++ b/src/main/java/com/postgraduate/domain/mentoring/application/dto/req/MentoringStatusRequest.java @@ -1,6 +1,5 @@ package com.postgraduate.domain.mentoring.application.dto.req; -import com.postgraduate.domain.mentoring.domain.entity.constant.Status; import jakarta.validation.constraints.NotNull; import lombok.AllArgsConstructor; import lombok.Getter; @@ -11,5 +10,5 @@ @NoArgsConstructor public class MentoringStatusRequest { @NotNull - private Status status; + private String refuse; } diff --git a/src/main/java/com/postgraduate/domain/mentoring/application/usecase/MentoringManageUseCase.java b/src/main/java/com/postgraduate/domain/mentoring/application/usecase/MentoringManageUseCase.java index f5bc6640..d389b745 100644 --- a/src/main/java/com/postgraduate/domain/mentoring/application/usecase/MentoringManageUseCase.java +++ b/src/main/java/com/postgraduate/domain/mentoring/application/usecase/MentoringManageUseCase.java @@ -1,9 +1,9 @@ package com.postgraduate.domain.mentoring.application.usecase; import com.postgraduate.domain.mentoring.application.dto.req.MentoringDateRequest; -import com.postgraduate.domain.mentoring.application.dto.req.MentoringRefuseRequest; import com.postgraduate.domain.mentoring.application.dto.req.MentoringStatusRequest; import com.postgraduate.domain.mentoring.domain.entity.Mentoring; +import com.postgraduate.domain.mentoring.domain.entity.constant.Status; import com.postgraduate.domain.mentoring.domain.service.MentoringUpdateService; import com.postgraduate.domain.mentoring.exception.MentoringNotWaitingException; import com.postgraduate.domain.senior.domain.entity.Senior; @@ -26,24 +26,25 @@ public class MentoringManageUseCase { private final SeniorGetService seniorGetService; private final CheckIsMyMentoringUseCase checkIsMyMentoringUseCase; - public void updateStatus(AuthDetails authDetails, Long mentoringId, MentoringStatusRequest request) { + public void updateStatus(AuthDetails authDetails, Long mentoringId, Status status) { User user = securityUtils.getLoggedInUser(authDetails); Mentoring mentoring = checkIsMyMentoringUseCase.checkByRole(user, mentoringId); - mentoringUpdateService.updateStatus(mentoring, request.getStatus()); + mentoringUpdateService.updateStatus(mentoring, status); } - public void updateSeniorStatus(AuthDetails authDetails, Long mentoringId, MentoringStatusRequest request) { + public void updateSeniorStatus(AuthDetails authDetails, Long mentoringId, Status status) { User user = securityUtils.getLoggedInUser(authDetails); Senior senior = seniorGetService.byUser(user); Mentoring mentoring = checkIsMyMentoringUseCase.checkByRole(senior, mentoringId); - mentoringUpdateService.updateStatus(mentoring, request.getStatus()); + mentoringUpdateService.updateStatus(mentoring, status); } - public void updateRefuse(AuthDetails authDetails, Long mentoringId, MentoringRefuseRequest request) { + public void updateRefuse(AuthDetails authDetails, Long mentoringId, MentoringStatusRequest request, Status status) { User user = securityUtils.getLoggedInUser(authDetails); Senior senior = seniorGetService.byUser(user); Mentoring mentoring = checkIsMyMentoringUseCase.checkByRole(senior, mentoringId); - mentoringUpdateService.updateStatus(mentoring, request.getRefuse()); + mentoringUpdateService.updateRefuse(mentoring, request.getRefuse()); + mentoringUpdateService.updateStatus(mentoring, status); } public void updateDate(AuthDetails authDetails, Long mentoringId, MentoringDateRequest request) { diff --git a/src/main/java/com/postgraduate/domain/mentoring/domain/service/MentoringUpdateService.java b/src/main/java/com/postgraduate/domain/mentoring/domain/service/MentoringUpdateService.java index 5942c986..ba0e6db6 100644 --- a/src/main/java/com/postgraduate/domain/mentoring/domain/service/MentoringUpdateService.java +++ b/src/main/java/com/postgraduate/domain/mentoring/domain/service/MentoringUpdateService.java @@ -16,7 +16,7 @@ public void updateStatus(Mentoring mentoring, Status status) { mentoring.updateStatus(status); } - public void updateStatus(Mentoring mentoring, String refuse) { + public void updateRefuse(Mentoring mentoring, String refuse) { mentoring.updateRefuse(refuse); } diff --git a/src/main/java/com/postgraduate/domain/mentoring/presentation/MentoringController.java b/src/main/java/com/postgraduate/domain/mentoring/presentation/MentoringController.java index 9f21984e..5fb53296 100644 --- a/src/main/java/com/postgraduate/domain/mentoring/presentation/MentoringController.java +++ b/src/main/java/com/postgraduate/domain/mentoring/presentation/MentoringController.java @@ -2,7 +2,6 @@ import com.postgraduate.domain.mentoring.application.dto.req.MentoringApplyRequest; import com.postgraduate.domain.mentoring.application.dto.req.MentoringDateRequest; -import com.postgraduate.domain.mentoring.application.dto.req.MentoringRefuseRequest; import com.postgraduate.domain.mentoring.application.dto.req.MentoringStatusRequest; import com.postgraduate.domain.mentoring.application.dto.res.AppliedMentoringDetailResponse; import com.postgraduate.domain.mentoring.application.dto.res.AppliedMentoringResponse; @@ -55,12 +54,11 @@ public ResponseDto applyMentoring(@AuthenticationPrincipal AuthDetails authDetai return ResponseDto.create(MENTORING_CREATE.getCode(), CREATE_MENTORING.getMessage()); } - @PatchMapping("/me/{mentoringId}") + @PatchMapping("/me/{mentoringId}/done") @Operation(summary = "[대학생] 멘토링 상태 업데이트", description = "대학생이 멘토링 상태를 변경합니다.") - public ResponseDto updateMentoringStatus(@AuthenticationPrincipal AuthDetails authDetails, - @PathVariable Long mentoringId, - @RequestBody MentoringStatusRequest request) { - manageUseCase.updateStatus(authDetails, mentoringId, request); + public ResponseDto updateMentoringDone(@AuthenticationPrincipal AuthDetails authDetails, + @PathVariable Long mentoringId) { + manageUseCase.updateStatus(authDetails, mentoringId, Status.DONE); return ResponseDto.create(MENTORING_UPDATE.getCode(), UPDATE_MENTORING.getMessage()); } @@ -80,28 +78,26 @@ public ResponseDto getSeniorMentoringDetail(@Auth @PatchMapping("/senior/me/{mentoringId}/time") @Operation(summary = "[대학원생] 멘토링 시간 선택", description = "대학생이 신청한 시간 옵션 3개 중 하나를 선택합니다. 확정 대기 상태의 멘토링만 가능합니다.") - public ResponseDto getSeniorMentorings(@AuthenticationPrincipal AuthDetails authDetails, + public ResponseDto updateMentoringDate(@AuthenticationPrincipal AuthDetails authDetails, @PathVariable Long mentoringId, @RequestBody MentoringDateRequest request) { manageUseCase.updateDate(authDetails, mentoringId, request); return ResponseDto.create(MENTORING_UPDATE.getCode(), UPDATE_MENTORING.getMessage()); } - @PatchMapping("/senior/me/{mentoringId}") - @Operation(summary = "[대학원생] 멘토링 상태 업데이트", description = "대학원생이 멘토링 상태를 변경합니다.") - public ResponseDto updateSeniorMentoringStatus(@AuthenticationPrincipal AuthDetails authDetails, - @PathVariable Long mentoringId, - @RequestBody MentoringStatusRequest request) { - manageUseCase.updateSeniorStatus(authDetails, mentoringId, request); + @PatchMapping("/senior/me/{mentoringId}/expected") + @Operation(summary = "[대학원생] 멘토링 상태 업데이트(예정된 멘토링)", description = "대학원생이 멘토링을 수락합니다.") + public ResponseDto updateMentoringExpected(@AuthenticationPrincipal AuthDetails authDetails, @PathVariable Long mentoringId) { + manageUseCase.updateSeniorStatus(authDetails, mentoringId, Status.EXPECTED); return ResponseDto.create(MENTORING_UPDATE.getCode(), UPDATE_MENTORING.getMessage()); } - @PatchMapping("/senior/me/{mentoringId}/refuse") - @Operation(summary = "[대학원생] 멘토링 거절사유 업데이트", description = "대학원생이 거절사유를 변경합니다.") - public ResponseDto updateSeniorMentoringStatus(@AuthenticationPrincipal AuthDetails authDetails, - @PathVariable Long mentoringId, - @RequestBody MentoringRefuseRequest request) { - manageUseCase.updateRefuse(authDetails, mentoringId, request); + @PatchMapping("/senior/me/{mentoringId}/cancel") + @Operation(summary = "[대학원생] 멘토링 상태 업데이트(거절)", description = "대학원생이 멘토링을 거절하고 거절사유를 변경합니다.") + public ResponseDto updateMentoringCancel(@AuthenticationPrincipal AuthDetails authDetails, + @PathVariable Long mentoringId, + @RequestBody MentoringStatusRequest request) { + manageUseCase.updateRefuse(authDetails, mentoringId, request, Status.CANCEL); return ResponseDto.create(MENTORING_UPDATE.getCode(), UPDATE_MENTORING.getMessage()); } } From d90444fcf2a2b2f3f50ee02192cc8fcf8ffe9b0e Mon Sep 17 00:00:00 2001 From: ay-eonii Date: Thu, 9 Nov 2023 12:34:11 +0900 Subject: [PATCH 20/24] =?UTF-8?q?RAC-103=20refactor:=20=EB=A9=98=ED=86=A0?= =?UTF-8?q?=EB=A7=81=20=EA=B4=80=EB=A6=AC=20=EA=B6=8C=ED=95=9C=20=ED=95=98?= =?UTF-8?q?=EB=82=98=EC=9D=98usecase=EC=97=90=EC=84=9C=20=EA=B4=80?= =?UTF-8?q?=EB=A6=AC=ED=95=98=EB=8F=84=EB=A1=9D=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../usecase/CheckIsMyMentoringUseCase.java | 13 +++++++++-- .../usecase/MentoringInfoUseCase.java | 7 ++---- .../usecase/MentoringManageUseCase.java | 23 ++++--------------- 3 files changed, 18 insertions(+), 25 deletions(-) diff --git a/src/main/java/com/postgraduate/domain/mentoring/application/usecase/CheckIsMyMentoringUseCase.java b/src/main/java/com/postgraduate/domain/mentoring/application/usecase/CheckIsMyMentoringUseCase.java index 671c8729..31e7f310 100644 --- a/src/main/java/com/postgraduate/domain/mentoring/application/usecase/CheckIsMyMentoringUseCase.java +++ b/src/main/java/com/postgraduate/domain/mentoring/application/usecase/CheckIsMyMentoringUseCase.java @@ -4,7 +4,10 @@ import com.postgraduate.domain.mentoring.domain.entity.Mentoring; import com.postgraduate.domain.mentoring.domain.service.MentoringGetService; import com.postgraduate.domain.senior.domain.entity.Senior; +import com.postgraduate.domain.senior.domain.service.SeniorGetService; import com.postgraduate.domain.user.domain.entity.User; +import com.postgraduate.global.auth.AuthDetails; +import com.postgraduate.global.config.security.util.SecurityUtils; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -13,8 +16,12 @@ @Transactional @RequiredArgsConstructor public class CheckIsMyMentoringUseCase { + private final SecurityUtils securityUtils; + private final SeniorGetService seniorGetService; private final MentoringGetService mentoringGetService; - public Mentoring checkByRole(User user, Long mentoringId) { + + public Mentoring byUser(AuthDetails authDetails, Long mentoringId) { + User user = securityUtils.getLoggedInUser(authDetails); Mentoring mentoring = mentoringGetService.byMentoringId(mentoringId); if (mentoring.getUser() != user) { throw new PermissionDeniedException(); @@ -22,7 +29,9 @@ public Mentoring checkByRole(User user, Long mentoringId) { return mentoring; } - public Mentoring checkByRole(Senior senior, Long mentoringId) { + public Mentoring bySenior(AuthDetails authDetails, Long mentoringId) { + User user = securityUtils.getLoggedInUser(authDetails); + Senior senior = seniorGetService.byUser(user); Mentoring mentoring = mentoringGetService.byMentoringId(mentoringId); if (mentoring.getSenior() != senior) { throw new PermissionDeniedException(); diff --git a/src/main/java/com/postgraduate/domain/mentoring/application/usecase/MentoringInfoUseCase.java b/src/main/java/com/postgraduate/domain/mentoring/application/usecase/MentoringInfoUseCase.java index b14e2237..36ca1c35 100644 --- a/src/main/java/com/postgraduate/domain/mentoring/application/usecase/MentoringInfoUseCase.java +++ b/src/main/java/com/postgraduate/domain/mentoring/application/usecase/MentoringInfoUseCase.java @@ -75,8 +75,7 @@ private AppliedMentoringResponse getCategories(Status status, List me } public AppliedMentoringDetailResponse getMentoringDetail(AuthDetails authDetails, Long mentoringId) { - User user = securityUtils.getLoggedInUser(authDetails); - Mentoring mentoring = checkIsMyMentoringUseCase.checkByRole(user, mentoringId); + Mentoring mentoring = checkIsMyMentoringUseCase.byUser(authDetails, mentoringId); if (mentoring.getStatus() != WAITING) { throw new MentoringNotWaitingException(); } @@ -84,9 +83,7 @@ public AppliedMentoringDetailResponse getMentoringDetail(AuthDetails authDetails } public SeniorMentoringDetailResponse getSeniorMentoringDetail(AuthDetails authDetails, Long mentoringId) { - User user = securityUtils.getLoggedInUser(authDetails); - Senior senior = seniorGetService.byUser(user); - Mentoring mentoring = checkIsMyMentoringUseCase.checkByRole(senior, mentoringId); + Mentoring mentoring = checkIsMyMentoringUseCase.bySenior(authDetails, mentoringId); if (mentoring.getStatus() == DONE) { throw new MentoringDoneException(); } diff --git a/src/main/java/com/postgraduate/domain/mentoring/application/usecase/MentoringManageUseCase.java b/src/main/java/com/postgraduate/domain/mentoring/application/usecase/MentoringManageUseCase.java index d389b745..391fc44c 100644 --- a/src/main/java/com/postgraduate/domain/mentoring/application/usecase/MentoringManageUseCase.java +++ b/src/main/java/com/postgraduate/domain/mentoring/application/usecase/MentoringManageUseCase.java @@ -6,11 +6,7 @@ import com.postgraduate.domain.mentoring.domain.entity.constant.Status; import com.postgraduate.domain.mentoring.domain.service.MentoringUpdateService; import com.postgraduate.domain.mentoring.exception.MentoringNotWaitingException; -import com.postgraduate.domain.senior.domain.entity.Senior; -import com.postgraduate.domain.senior.domain.service.SeniorGetService; -import com.postgraduate.domain.user.domain.entity.User; import com.postgraduate.global.auth.AuthDetails; -import com.postgraduate.global.config.security.util.SecurityUtils; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -21,36 +17,27 @@ @Transactional @RequiredArgsConstructor public class MentoringManageUseCase { - private final SecurityUtils securityUtils; - private final MentoringUpdateService mentoringUpdateService; - private final SeniorGetService seniorGetService; private final CheckIsMyMentoringUseCase checkIsMyMentoringUseCase; + private final MentoringUpdateService mentoringUpdateService; public void updateStatus(AuthDetails authDetails, Long mentoringId, Status status) { - User user = securityUtils.getLoggedInUser(authDetails); - Mentoring mentoring = checkIsMyMentoringUseCase.checkByRole(user, mentoringId); + Mentoring mentoring = checkIsMyMentoringUseCase.byUser(authDetails, mentoringId); mentoringUpdateService.updateStatus(mentoring, status); } public void updateSeniorStatus(AuthDetails authDetails, Long mentoringId, Status status) { - User user = securityUtils.getLoggedInUser(authDetails); - Senior senior = seniorGetService.byUser(user); - Mentoring mentoring = checkIsMyMentoringUseCase.checkByRole(senior, mentoringId); + Mentoring mentoring = checkIsMyMentoringUseCase.bySenior(authDetails, mentoringId); mentoringUpdateService.updateStatus(mentoring, status); } public void updateRefuse(AuthDetails authDetails, Long mentoringId, MentoringStatusRequest request, Status status) { - User user = securityUtils.getLoggedInUser(authDetails); - Senior senior = seniorGetService.byUser(user); - Mentoring mentoring = checkIsMyMentoringUseCase.checkByRole(senior, mentoringId); + Mentoring mentoring = checkIsMyMentoringUseCase.bySenior(authDetails, mentoringId); mentoringUpdateService.updateRefuse(mentoring, request.getRefuse()); mentoringUpdateService.updateStatus(mentoring, status); } public void updateDate(AuthDetails authDetails, Long mentoringId, MentoringDateRequest request) { - User user = securityUtils.getLoggedInUser(authDetails); - Senior senior = seniorGetService.byUser(user); - Mentoring mentoring = checkIsMyMentoringUseCase.checkByRole(senior, mentoringId); + Mentoring mentoring = checkIsMyMentoringUseCase.bySenior(authDetails, mentoringId); if (mentoring.getStatus() != WAITING) { throw new MentoringNotWaitingException(); } From 5b987c658339c1edd0c22a759b00ec3ccc812427 Mon Sep 17 00:00:00 2001 From: ay-eonii Date: Thu, 9 Nov 2023 12:34:27 +0900 Subject: [PATCH 21/24] =?UTF-8?q?RAC-103=20test:=20=EB=A9=98=ED=86=A0?= =?UTF-8?q?=EB=A7=81=20=EA=B4=80=EB=A6=AC=20=EA=B6=8C=ED=95=9C=20=ED=85=8C?= =?UTF-8?q?=EC=8A=A4=ED=8A=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../usecase/CheckIsMyMentoringUseCaseTest.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/test/java/com/postgraduate/domain/mentoring/application/usecase/CheckIsMyMentoringUseCaseTest.java b/src/test/java/com/postgraduate/domain/mentoring/application/usecase/CheckIsMyMentoringUseCaseTest.java index 717cca05..ae46d86f 100644 --- a/src/test/java/com/postgraduate/domain/mentoring/application/usecase/CheckIsMyMentoringUseCaseTest.java +++ b/src/test/java/com/postgraduate/domain/mentoring/application/usecase/CheckIsMyMentoringUseCaseTest.java @@ -3,6 +3,8 @@ import com.postgraduate.domain.mentoring.domain.entity.Mentoring; import com.postgraduate.domain.mentoring.domain.service.MentoringGetService; import com.postgraduate.domain.user.domain.entity.User; +import com.postgraduate.global.auth.AuthDetails; +import com.postgraduate.global.config.security.util.SecurityUtils; import com.postgraduate.global.exception.ApplicationException; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -19,12 +21,16 @@ class CheckIsMyMentoringUseCaseTest { @Mock private MentoringGetService mentoringGetService; + @Mock + private SecurityUtils securityUtils; + @InjectMocks private CheckIsMyMentoringUseCase checkIsMyMentoringUseCase; @Test public void testCheckByRoleInvalid() { - User user = new User(); + AuthDetails authDetails = mock(AuthDetails.class); + when(securityUtils.getLoggedInUser(authDetails)).thenReturn(new User()); Long mentoringId = 1L; Mentoring mentoring = mock(); @@ -32,7 +38,7 @@ public void testCheckByRoleInvalid() { when(mentoringGetService.byMentoringId(mentoringId)).thenReturn(mentoring); assertThrows(ApplicationException.class, () -> { - checkIsMyMentoringUseCase.checkByRole(user, mentoringId); + checkIsMyMentoringUseCase.byUser(authDetails, mentoringId); }); } } \ No newline at end of file From 08565e5d038091d733163ff25c7fc7dce2166bf5 Mon Sep 17 00:00:00 2001 From: ay-eonii Date: Thu, 9 Nov 2023 12:44:27 +0900 Subject: [PATCH 22/24] =?UTF-8?q?RAC-103=20feat:=20=EB=8C=80=ED=95=99?= =?UTF-8?q?=EC=83=9D=20=EB=A9=98=ED=86=A0=EB=A7=81=20=EC=B7=A8=EC=86=8C=20?= =?UTF-8?q?api=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mentoring/presentation/MentoringController.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/postgraduate/domain/mentoring/presentation/MentoringController.java b/src/main/java/com/postgraduate/domain/mentoring/presentation/MentoringController.java index 5fb53296..05519354 100644 --- a/src/main/java/com/postgraduate/domain/mentoring/presentation/MentoringController.java +++ b/src/main/java/com/postgraduate/domain/mentoring/presentation/MentoringController.java @@ -55,13 +55,21 @@ public ResponseDto applyMentoring(@AuthenticationPrincipal AuthDetails authDetai } @PatchMapping("/me/{mentoringId}/done") - @Operation(summary = "[대학생] 멘토링 상태 업데이트", description = "대학생이 멘토링 상태를 변경합니다.") + @Operation(summary = "[대학생] 멘토링 상태 업데이트(완료)", description = "대학생이 멘토링을 완료합니다.") public ResponseDto updateMentoringDone(@AuthenticationPrincipal AuthDetails authDetails, - @PathVariable Long mentoringId) { + @PathVariable Long mentoringId) { manageUseCase.updateStatus(authDetails, mentoringId, Status.DONE); return ResponseDto.create(MENTORING_UPDATE.getCode(), UPDATE_MENTORING.getMessage()); } + @PatchMapping("/me/{mentoringId}/cancel") + @Operation(summary = "[대학생] 멘토링 상태 업데이트(취소)", description = "대학생이 신청한 멘토링을 취소합니다.") + public ResponseDto updateMentoringCancel(@AuthenticationPrincipal AuthDetails authDetails, + @PathVariable Long mentoringId) { + manageUseCase.updateStatus(authDetails, mentoringId, Status.CANCEL); + return ResponseDto.create(MENTORING_UPDATE.getCode(), UPDATE_MENTORING.getMessage()); + } + @GetMapping("/senior/me") @Operation(summary = "[대학원생] 신청받은 멘토링 목록 조회", description = "대학원생이 신청받은 멘토링 목록을 조회합니다.") public ResponseDto> getSeniorMentorings(@RequestParam Status status, @AuthenticationPrincipal AuthDetails authDetails) { From a60152d238990d003bb42e725bde17ba02bf95ef Mon Sep 17 00:00:00 2001 From: ay-eonii Date: Thu, 9 Nov 2023 13:10:55 +0900 Subject: [PATCH 23/24] =?UTF-8?q?RAC-103=20fix:=20MentoringStatusRequest?= =?UTF-8?q?=20=EB=8C=80=EC=8B=A0=20MentoringRefuseRequest=20=EC=82=AC?= =?UTF-8?q?=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/req/MentoringStatusRequest.java | 14 -------------- .../usecase/MentoringManageUseCase.java | 4 ++-- .../presentation/MentoringController.java | 4 ++-- 3 files changed, 4 insertions(+), 18 deletions(-) delete mode 100644 src/main/java/com/postgraduate/domain/mentoring/application/dto/req/MentoringStatusRequest.java diff --git a/src/main/java/com/postgraduate/domain/mentoring/application/dto/req/MentoringStatusRequest.java b/src/main/java/com/postgraduate/domain/mentoring/application/dto/req/MentoringStatusRequest.java deleted file mode 100644 index 1b0b7b23..00000000 --- a/src/main/java/com/postgraduate/domain/mentoring/application/dto/req/MentoringStatusRequest.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.postgraduate.domain.mentoring.application.dto.req; - -import jakarta.validation.constraints.NotNull; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; - -@Getter -@AllArgsConstructor -@NoArgsConstructor -public class MentoringStatusRequest { - @NotNull - private String refuse; -} diff --git a/src/main/java/com/postgraduate/domain/mentoring/application/usecase/MentoringManageUseCase.java b/src/main/java/com/postgraduate/domain/mentoring/application/usecase/MentoringManageUseCase.java index 391fc44c..7859f66c 100644 --- a/src/main/java/com/postgraduate/domain/mentoring/application/usecase/MentoringManageUseCase.java +++ b/src/main/java/com/postgraduate/domain/mentoring/application/usecase/MentoringManageUseCase.java @@ -1,7 +1,7 @@ package com.postgraduate.domain.mentoring.application.usecase; import com.postgraduate.domain.mentoring.application.dto.req.MentoringDateRequest; -import com.postgraduate.domain.mentoring.application.dto.req.MentoringStatusRequest; +import com.postgraduate.domain.mentoring.application.dto.req.MentoringRefuseRequest; import com.postgraduate.domain.mentoring.domain.entity.Mentoring; import com.postgraduate.domain.mentoring.domain.entity.constant.Status; import com.postgraduate.domain.mentoring.domain.service.MentoringUpdateService; @@ -30,7 +30,7 @@ public void updateSeniorStatus(AuthDetails authDetails, Long mentoringId, Status mentoringUpdateService.updateStatus(mentoring, status); } - public void updateRefuse(AuthDetails authDetails, Long mentoringId, MentoringStatusRequest request, Status status) { + public void updateRefuse(AuthDetails authDetails, Long mentoringId, MentoringRefuseRequest request, Status status) { Mentoring mentoring = checkIsMyMentoringUseCase.bySenior(authDetails, mentoringId); mentoringUpdateService.updateRefuse(mentoring, request.getRefuse()); mentoringUpdateService.updateStatus(mentoring, status); diff --git a/src/main/java/com/postgraduate/domain/mentoring/presentation/MentoringController.java b/src/main/java/com/postgraduate/domain/mentoring/presentation/MentoringController.java index 05519354..cc4dff86 100644 --- a/src/main/java/com/postgraduate/domain/mentoring/presentation/MentoringController.java +++ b/src/main/java/com/postgraduate/domain/mentoring/presentation/MentoringController.java @@ -2,7 +2,7 @@ import com.postgraduate.domain.mentoring.application.dto.req.MentoringApplyRequest; import com.postgraduate.domain.mentoring.application.dto.req.MentoringDateRequest; -import com.postgraduate.domain.mentoring.application.dto.req.MentoringStatusRequest; +import com.postgraduate.domain.mentoring.application.dto.req.MentoringRefuseRequest; import com.postgraduate.domain.mentoring.application.dto.res.AppliedMentoringDetailResponse; import com.postgraduate.domain.mentoring.application.dto.res.AppliedMentoringResponse; import com.postgraduate.domain.mentoring.application.dto.res.SeniorMentoringDetailResponse; @@ -104,7 +104,7 @@ public ResponseDto updateMentoringExpected(@AuthenticationPrincipal AuthDetails @Operation(summary = "[대학원생] 멘토링 상태 업데이트(거절)", description = "대학원생이 멘토링을 거절하고 거절사유를 변경합니다.") public ResponseDto updateMentoringCancel(@AuthenticationPrincipal AuthDetails authDetails, @PathVariable Long mentoringId, - @RequestBody MentoringStatusRequest request) { + @RequestBody MentoringRefuseRequest request) { manageUseCase.updateRefuse(authDetails, mentoringId, request, Status.CANCEL); return ResponseDto.create(MENTORING_UPDATE.getCode(), UPDATE_MENTORING.getMessage()); } From cc74d73c95bbd428ba803f3ccb986bcb7d22465b Mon Sep 17 00:00:00 2001 From: ay-eonii Date: Thu, 9 Nov 2023 13:11:29 +0900 Subject: [PATCH 24/24] =?UTF-8?q?RAC-103=20fix:=20=EB=A9=98=ED=86=A0?= =?UTF-8?q?=EB=A7=81=20=EC=98=88=EC=99=B8=20=EC=BD=94=EB=93=9C=20700?= =?UTF-8?q?=EB=B2=88=EB=8C=80=EB=A1=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../presentation/constant/MentoringResponseCode.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/postgraduate/domain/mentoring/presentation/constant/MentoringResponseCode.java b/src/main/java/com/postgraduate/domain/mentoring/presentation/constant/MentoringResponseCode.java index 895ca3e0..cec8ef39 100644 --- a/src/main/java/com/postgraduate/domain/mentoring/presentation/constant/MentoringResponseCode.java +++ b/src/main/java/com/postgraduate/domain/mentoring/presentation/constant/MentoringResponseCode.java @@ -11,9 +11,9 @@ public enum MentoringResponseCode { MENTORING_CREATE("MT202"), MENTORING_DELETE("MT203"), - MENTORING_NOT_FOUND("EX901"), - MENTORING_DONE("EX902"), - MENTORING_NOT_WAITING("EX903"), + MENTORING_NOT_FOUND("EX700"), + MENTORING_DONE("EX701"), + MENTORING_NOT_WAITING("EX702"), ; private final String code; } \ No newline at end of file