From 8d910b4669162a5128326611b420da260d756553 Mon Sep 17 00:00:00 2001 From: sukangpunch Date: Mon, 27 Oct 2025 19:55:36 +0900 Subject: [PATCH 01/10] =?UTF-8?q?feat:=20=EB=A9=98=ED=86=A0=20=EB=A7=88?= =?UTF-8?q?=EC=9D=B4=ED=8E=98=EC=9D=B4=EC=A7=80=20=EC=83=9D=EC=84=B1=20?= =?UTF-8?q?=EA=B8=B0=EB=8A=A5=20=EC=B6=94=EA=B0=80=20-=201=EC=B0=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: 멘토 마이페이지 생성 기능 추가 * fix: 멘토 엔티티에 universityId 가 null 을 허용하도록 수정 * feat: MentorStatus enum 클래스 추가 * fix: MentorApplicationRequest 에 term 추가 - 멘토 승격 지원 시 수학한 term 을 입력 받아야 한다 * feat: Role 에 TEMP_MENTOR 추가 * test: MentorApplicationFixture 에 term 추가 --- .../common/exception/ErrorCode.java | 2 + .../controller/MentorMyPageController.java | 11 +++++ .../solidconnection/mentor/domain/Mentor.java | 30 +++++++++++- .../mentor/domain/MentorApplication.java | 5 ++ .../mentor/domain/MentorStatus.java | 10 ++++ .../mentor/dto/MentorApplicationRequest.java | 3 +- .../dto/MentorProfileCreateRequest.java | 20 ++++++++ .../MentorApplicationRepository.java | 3 ++ .../service/MentorApplicationService.java | 3 +- .../mentor/service/MentorMyPageService.java | 47 ++++++++++++++++++- .../news/domain/NewsStatus.java | 8 ++++ .../solidconnection/siteuser/domain/Role.java | 4 +- .../MentorApplicationFixtureBuilder.java | 7 +++ .../mentor/fixture/MentorFixtureBuilder.java | 2 +- .../service/MentorApplicationServiceTest.java | 3 +- 15 files changed, 150 insertions(+), 8 deletions(-) create mode 100644 src/main/java/com/example/solidconnection/mentor/domain/MentorStatus.java create mode 100644 src/main/java/com/example/solidconnection/mentor/dto/MentorProfileCreateRequest.java create mode 100644 src/main/java/com/example/solidconnection/news/domain/NewsStatus.java diff --git a/src/main/java/com/example/solidconnection/common/exception/ErrorCode.java b/src/main/java/com/example/solidconnection/common/exception/ErrorCode.java index fae3c4980..3c45c97f6 100644 --- a/src/main/java/com/example/solidconnection/common/exception/ErrorCode.java +++ b/src/main/java/com/example/solidconnection/common/exception/ErrorCode.java @@ -50,6 +50,7 @@ public enum ErrorCode { BLOCK_USER_NOT_FOUND(HttpStatus.NOT_FOUND.value(), "차단 대상 사용자를 찾을 수 없습니다."), TERM_NOT_FOUND(HttpStatus.NOT_FOUND.value(), "존재하지 않는 학기입니다."), CURRENT_TERM_NOT_FOUND(HttpStatus.NOT_FOUND.value(), "현재 학기를 찾을 수 없습니다."), + MENTOR_APPLICATION_NOT_FOUND(HttpStatus.NOT_FOUND.value(), "멘토 프로필이 존재하지 않습니다."), // auth USER_ALREADY_SIGN_OUT(HttpStatus.UNAUTHORIZED.value(), "로그아웃 되었습니다."), @@ -126,6 +127,7 @@ public enum ErrorCode { UNIVERSITY_ID_REQUIRED_FOR_CATALOG(HttpStatus.BAD_REQUEST.value(), "목록에서 학교를 선택한 경우 학교 정보가 필요합니다."), UNIVERSITY_ID_MUST_BE_NULL_FOR_OTHER(HttpStatus.BAD_REQUEST.value(), "기타 학교를 선택한 경우 학교 정보를 입력할 수 없습니다."), INVALID_UNIVERSITY_SELECT_TYPE(HttpStatus.BAD_REQUEST.value(), "지원하지 않는 학교 선택 방식입니다."), + MENTOR_ALREADY_EXISTS(HttpStatus.BAD_REQUEST.value(), "이미 멘토 마이 페이지가 존재합니다" ), // socket UNAUTHORIZED_SUBSCRIBE(HttpStatus.FORBIDDEN.value(), "구독 권한이 없습니다."), diff --git a/src/main/java/com/example/solidconnection/mentor/controller/MentorMyPageController.java b/src/main/java/com/example/solidconnection/mentor/controller/MentorMyPageController.java index dd9289a3e..4896489c1 100644 --- a/src/main/java/com/example/solidconnection/mentor/controller/MentorMyPageController.java +++ b/src/main/java/com/example/solidconnection/mentor/controller/MentorMyPageController.java @@ -3,6 +3,7 @@ import com.example.solidconnection.common.resolver.AuthorizedUser; import com.example.solidconnection.mentor.dto.MentorMyPageResponse; import com.example.solidconnection.mentor.dto.MentorMyPageUpdateRequest; +import com.example.solidconnection.mentor.dto.MentorProfileCreateRequest; import com.example.solidconnection.mentor.service.MentorMyPageService; import com.example.solidconnection.security.annotation.RequireRoleAccess; import com.example.solidconnection.siteuser.domain.Role; @@ -10,6 +11,7 @@ import lombok.RequiredArgsConstructor; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; @@ -40,4 +42,13 @@ public ResponseEntity updateMentorMyPage( mentorMyPageService.updateMentorMyPage(siteUserId, mentorMyPageUpdateRequest); return ResponseEntity.ok().build(); } + + @PostMapping + public ResponseEntity createMentorMyPage( + @AuthorizedUser long siteUserId, + @Valid @RequestBody MentorProfileCreateRequest request + ) { + mentorMyPageService.createMentorMyPage(siteUserId, request); + return ResponseEntity.ok().build(); + } } diff --git a/src/main/java/com/example/solidconnection/mentor/domain/Mentor.java b/src/main/java/com/example/solidconnection/mentor/domain/Mentor.java index 420170236..38980f208 100644 --- a/src/main/java/com/example/solidconnection/mentor/domain/Mentor.java +++ b/src/main/java/com/example/solidconnection/mentor/domain/Mentor.java @@ -4,6 +4,8 @@ import jakarta.persistence.CascadeType; import jakarta.persistence.Column; import jakarta.persistence.Entity; +import jakarta.persistence.EnumType; +import jakarta.persistence.Enumerated; import jakarta.persistence.GeneratedValue; import jakarta.persistence.GenerationType; import jakarta.persistence.Id; @@ -43,7 +45,7 @@ public class Mentor extends BaseEntity { private long siteUserId; @Column - private long universityId; + private Long universityId; // 임시 멘토일 때, null 가능 @Column(nullable = false, name = "term_id") private long termId; @@ -53,6 +55,25 @@ public class Mentor extends BaseEntity { @OneToMany(mappedBy = "mentor", cascade = CascadeType.ALL, orphanRemoval = true) private List channels = new ArrayList<>(); + @Column(nullable = false) + @Enumerated(EnumType.STRING) + private MentorStatus mentorStatus; + + public Mentor( + String introduction, + String passTip, + long siteUserId, + Long universityId, + String term + ) { + this.introduction = introduction; + this.passTip = passTip; + this.siteUserId = siteUserId; + this.universityId = universityId; + this.term = term; + this.mentorStatus = MentorStatus.TEMPORARY; + } + public void increaseMenteeCount() { this.menteeCount++; } @@ -82,4 +103,11 @@ public void updateChannels(List channels) { } } } + + public void createChannels(List channels) { + for(Channel channel : channels) { + channel.updateMentor(this); + this.channels.add(channel); + } + } } diff --git a/src/main/java/com/example/solidconnection/mentor/domain/MentorApplication.java b/src/main/java/com/example/solidconnection/mentor/domain/MentorApplication.java index 8f800dcff..d6ce71af7 100644 --- a/src/main/java/com/example/solidconnection/mentor/domain/MentorApplication.java +++ b/src/main/java/com/example/solidconnection/mentor/domain/MentorApplication.java @@ -53,6 +53,9 @@ public class MentorApplication extends BaseEntity { @Column(nullable = false, name = "mentor_proof_url", length = 500) private String mentorProofUrl; + @Column(length = 50, nullable = false) + private String term; + private String rejectedReason; @Column(nullable = false) @@ -72,6 +75,7 @@ public MentorApplication( Long universityId, UniversitySelectType universitySelectType, String mentorProofUrl, + String term, ExchangeStatus exchangeStatus ) { validateExchangeStatus(exchangeStatus); @@ -82,6 +86,7 @@ public MentorApplication( this.universityId = universityId; this.universitySelectType = universitySelectType; this.mentorProofUrl = mentorProofUrl; + this.term = term; this.exchangeStatus = exchangeStatus; } diff --git a/src/main/java/com/example/solidconnection/mentor/domain/MentorStatus.java b/src/main/java/com/example/solidconnection/mentor/domain/MentorStatus.java new file mode 100644 index 000000000..3b1cb6f30 --- /dev/null +++ b/src/main/java/com/example/solidconnection/mentor/domain/MentorStatus.java @@ -0,0 +1,10 @@ +package com.example.solidconnection.mentor.domain; + +public enum MentorStatus { + + TEMPORARY, + APPROVED, + REJECTED, + ; + +} diff --git a/src/main/java/com/example/solidconnection/mentor/dto/MentorApplicationRequest.java b/src/main/java/com/example/solidconnection/mentor/dto/MentorApplicationRequest.java index da6d206ab..1007a074b 100644 --- a/src/main/java/com/example/solidconnection/mentor/dto/MentorApplicationRequest.java +++ b/src/main/java/com/example/solidconnection/mentor/dto/MentorApplicationRequest.java @@ -9,6 +9,7 @@ public record MentorApplicationRequest( ExchangeStatus exchangeStatus, UniversitySelectType universitySelectType, String country, - Long universityId + Long universityId, + String term ) { } diff --git a/src/main/java/com/example/solidconnection/mentor/dto/MentorProfileCreateRequest.java b/src/main/java/com/example/solidconnection/mentor/dto/MentorProfileCreateRequest.java new file mode 100644 index 000000000..a34fc6a9a --- /dev/null +++ b/src/main/java/com/example/solidconnection/mentor/dto/MentorProfileCreateRequest.java @@ -0,0 +1,20 @@ +package com.example.solidconnection.mentor.dto; + +import jakarta.validation.Valid; +import jakarta.validation.constraints.NotBlank; +import java.util.List; + +public record MentorProfileCreateRequest( + Long universityId, + + @NotBlank(message = "자기소개를 입력해주세요.") + String introduction, + + @NotBlank(message = "합격 레시피를 입력해주세요.") + String passTip, + + @Valid + List channels +) { + +} diff --git a/src/main/java/com/example/solidconnection/mentor/repository/MentorApplicationRepository.java b/src/main/java/com/example/solidconnection/mentor/repository/MentorApplicationRepository.java index d03b53892..fb2ab5191 100644 --- a/src/main/java/com/example/solidconnection/mentor/repository/MentorApplicationRepository.java +++ b/src/main/java/com/example/solidconnection/mentor/repository/MentorApplicationRepository.java @@ -3,9 +3,12 @@ import com.example.solidconnection.mentor.domain.MentorApplication; import com.example.solidconnection.mentor.domain.MentorApplicationStatus; import java.util.List; +import java.util.Optional; import org.springframework.data.jpa.repository.JpaRepository; public interface MentorApplicationRepository extends JpaRepository { boolean existsBySiteUserIdAndMentorApplicationStatusIn(long siteUserId, List mentorApplicationStatuses); + + Optional findBySiteUserId(long siteUserId); } diff --git a/src/main/java/com/example/solidconnection/mentor/service/MentorApplicationService.java b/src/main/java/com/example/solidconnection/mentor/service/MentorApplicationService.java index d0716a156..14eb74c99 100644 --- a/src/main/java/com/example/solidconnection/mentor/service/MentorApplicationService.java +++ b/src/main/java/com/example/solidconnection/mentor/service/MentorApplicationService.java @@ -51,8 +51,9 @@ public void submitMentorApplication( mentorApplicationRequest.universityId(), mentorApplicationRequest.universitySelectType(), uploadedFile.fileUrl(), + mentorApplicationRequest.term(), mentorApplicationRequest.exchangeStatus() ); mentorApplicationRepository.save(mentorApplication); } -} +} \ No newline at end of file diff --git a/src/main/java/com/example/solidconnection/mentor/service/MentorMyPageService.java b/src/main/java/com/example/solidconnection/mentor/service/MentorMyPageService.java index 810891b2b..a60a45131 100644 --- a/src/main/java/com/example/solidconnection/mentor/service/MentorMyPageService.java +++ b/src/main/java/com/example/solidconnection/mentor/service/MentorMyPageService.java @@ -1,6 +1,8 @@ package com.example.solidconnection.mentor.service; import static com.example.solidconnection.common.exception.ErrorCode.CHANNEL_REGISTRATION_LIMIT_EXCEEDED; +import static com.example.solidconnection.common.exception.ErrorCode.MENTOR_ALREADY_EXISTS; +import static com.example.solidconnection.common.exception.ErrorCode.MENTOR_APPLICATION_ALREADY_EXISTED; import static com.example.solidconnection.common.exception.ErrorCode.MENTOR_NOT_FOUND; import static com.example.solidconnection.common.exception.ErrorCode.TERM_NOT_FOUND; import static com.example.solidconnection.common.exception.ErrorCode.UNIVERSITY_NOT_FOUND; @@ -9,9 +11,12 @@ import com.example.solidconnection.common.exception.CustomException; import com.example.solidconnection.mentor.domain.Channel; import com.example.solidconnection.mentor.domain.Mentor; +import com.example.solidconnection.mentor.domain.MentorApplication; import com.example.solidconnection.mentor.dto.ChannelRequest; import com.example.solidconnection.mentor.dto.MentorMyPageResponse; import com.example.solidconnection.mentor.dto.MentorMyPageUpdateRequest; +import com.example.solidconnection.mentor.dto.MentorProfileCreateRequest; +import com.example.solidconnection.mentor.repository.MentorApplicationRepository; import com.example.solidconnection.mentor.repository.MentorRepository; import com.example.solidconnection.siteuser.domain.SiteUser; import com.example.solidconnection.siteuser.repository.SiteUserRepository; @@ -35,6 +40,7 @@ public class MentorMyPageService { private final MentorRepository mentorRepository; private final SiteUserRepository siteUserRepository; private final UniversityRepository universityRepository; + private final MentorApplicationRepository mentorApplicationRepository; private final TermRepository termRepository; @Transactional(readOnly = true) @@ -61,18 +67,55 @@ public void updateMentorMyPage(long siteUserId, MentorMyPageUpdateRequest reques updateChannel(request.channels(), mentor); } + private void updateChannel(List channelRequests, Mentor mentor) { + int sequence = CHANNEL_SEQUENCE_START_NUMBER; + List newChannels = new ArrayList<>(); + for (ChannelRequest request : channelRequests) { + newChannels.add(new Channel(sequence++, request.type(), request.url())); + } + mentor.updateChannels(newChannels); + } + + public void createMentorMyPage(long siteUserId, MentorProfileCreateRequest request) { + validateUserCanCreateMentor(siteUserId); + validateChannelRegistrationLimit(request.channels()); + MentorApplication mentorApplication = mentorApplicationRepository.findBySiteUserId(siteUserId) + .orElseThrow(()->new CustomException(MENTOR_APPLICATION_ALREADY_EXISTED)); + + Mentor mentor = new Mentor( + request.introduction(), + request.passTip(), + siteUserId, + request.universityId(), + mentorApplication.getTerm() + ); + + createChannels(request.channels(), mentor); + mentorRepository.save(mentor); + } + + private void validateUserCanCreateMentor(long siteUserId){ + if(!siteUserRepository.existsById(siteUserId)) { + throw new CustomException(USER_NOT_FOUND); + } + + if(mentorRepository.existsBySiteUserId(siteUserId)) { + throw new CustomException(MENTOR_ALREADY_EXISTS); + } + } + private void validateChannelRegistrationLimit(List channelRequests) { if (channelRequests.size() > CHANNEL_REGISTRATION_LIMIT) { throw new CustomException(CHANNEL_REGISTRATION_LIMIT_EXCEEDED); } } - private void updateChannel(List channelRequests, Mentor mentor) { + private void createChannels(List channelRequests, Mentor mentor) { int sequence = CHANNEL_SEQUENCE_START_NUMBER; List newChannels = new ArrayList<>(); for (ChannelRequest request : channelRequests) { newChannels.add(new Channel(sequence++, request.type(), request.url())); } - mentor.updateChannels(newChannels); + mentor.createChannels(newChannels); } } diff --git a/src/main/java/com/example/solidconnection/news/domain/NewsStatus.java b/src/main/java/com/example/solidconnection/news/domain/NewsStatus.java new file mode 100644 index 000000000..ee5840035 --- /dev/null +++ b/src/main/java/com/example/solidconnection/news/domain/NewsStatus.java @@ -0,0 +1,8 @@ +package com.example.solidconnection.news.domain; + +public enum NewsStatus { + + TEMPORARY, + APPROVED, + ; +} diff --git a/src/main/java/com/example/solidconnection/siteuser/domain/Role.java b/src/main/java/com/example/solidconnection/siteuser/domain/Role.java index 4ea5bf151..6d8c88e8e 100644 --- a/src/main/java/com/example/solidconnection/siteuser/domain/Role.java +++ b/src/main/java/com/example/solidconnection/siteuser/domain/Role.java @@ -4,5 +4,7 @@ public enum Role { ADMIN, MENTOR, - MENTEE; + MENTEE, + TEMP_MENTOR + ; } diff --git a/src/test/java/com/example/solidconnection/mentor/fixture/MentorApplicationFixtureBuilder.java b/src/test/java/com/example/solidconnection/mentor/fixture/MentorApplicationFixtureBuilder.java index fc6fe547d..8344133b7 100644 --- a/src/test/java/com/example/solidconnection/mentor/fixture/MentorApplicationFixtureBuilder.java +++ b/src/test/java/com/example/solidconnection/mentor/fixture/MentorApplicationFixtureBuilder.java @@ -20,6 +20,7 @@ public class MentorApplicationFixtureBuilder { private Long universityId = null; private UniversitySelectType universitySelectType = UniversitySelectType.OTHER; private String mentorProofUrl = "/mentor-proof.pdf"; + private String term = "2025-1"; private ExchangeStatus exchangeStatus = ExchangeStatus.AFTER_EXCHANGE; private MentorApplicationStatus mentorApplicationStatus = MentorApplicationStatus.PENDING; @@ -52,6 +53,11 @@ public MentorApplicationFixtureBuilder mentorProofUrl(String mentorProofUrl) { return this; } + public MentorApplicationFixtureBuilder term(String term) { + this.term = term; + return this; + } + public MentorApplicationFixtureBuilder exchangeStatus(ExchangeStatus exchangeStatus) { this.exchangeStatus = exchangeStatus; return this; @@ -69,6 +75,7 @@ public MentorApplication create() { universityId, universitySelectType, mentorProofUrl, + term, exchangeStatus ); ReflectionTestUtils.setField(mentorApplication, "mentorApplicationStatus", mentorApplicationStatus); diff --git a/src/test/java/com/example/solidconnection/mentor/fixture/MentorFixtureBuilder.java b/src/test/java/com/example/solidconnection/mentor/fixture/MentorFixtureBuilder.java index 533d29494..12667bd22 100644 --- a/src/test/java/com/example/solidconnection/mentor/fixture/MentorFixtureBuilder.java +++ b/src/test/java/com/example/solidconnection/mentor/fixture/MentorFixtureBuilder.java @@ -67,7 +67,7 @@ public Mentor create() { passTip, siteUserId, universityId, - termId, + term, null ); return mentorRepository.save(mentor); diff --git a/src/test/java/com/example/solidconnection/mentor/service/MentorApplicationServiceTest.java b/src/test/java/com/example/solidconnection/mentor/service/MentorApplicationServiceTest.java index aaf63b600..abebaf2a3 100644 --- a/src/test/java/com/example/solidconnection/mentor/service/MentorApplicationServiceTest.java +++ b/src/test/java/com/example/solidconnection/mentor/service/MentorApplicationServiceTest.java @@ -190,7 +190,8 @@ private MentorApplicationRequest createMentorApplicationRequest(UniversitySelect ExchangeStatus.AFTER_EXCHANGE, universitySelectType, "US", - universityId + universityId, + "2025-1" ); } } From b3c34dad4076e6e523abfed4fa65a75f8dcbea52 Mon Sep 17 00:00:00 2001 From: sukangpunch Date: Tue, 4 Nov 2025 14:42:23 +0900 Subject: [PATCH 02/10] =?UTF-8?q?feat:=20=EB=A9=98=ED=86=A0=20=EC=8A=B9?= =?UTF-8?q?=EA=B2=A9=20=EC=9A=94=EC=B2=AD=20=EC=9D=B4=ED=9B=84=20TEMP=5FRO?= =?UTF-8?q?LE=20=EB=B6=80=EC=97=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mentor/controller/MentorMyPageController.java | 6 +++++- .../mentor/service/MentorApplicationService.java | 5 +++++ .../solidconnection/mentor/service/MentorMyPageService.java | 5 +++++ .../example/solidconnection/siteuser/domain/SiteUser.java | 4 ++++ 4 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/example/solidconnection/mentor/controller/MentorMyPageController.java b/src/main/java/com/example/solidconnection/mentor/controller/MentorMyPageController.java index 4896489c1..42e30b1c6 100644 --- a/src/main/java/com/example/solidconnection/mentor/controller/MentorMyPageController.java +++ b/src/main/java/com/example/solidconnection/mentor/controller/MentorMyPageController.java @@ -9,6 +9,7 @@ import com.example.solidconnection.siteuser.domain.Role; import jakarta.validation.Valid; import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; @@ -17,6 +18,7 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +@Slf4j @RequiredArgsConstructor @RequestMapping("/mentor/my") @RestController @@ -33,7 +35,7 @@ public ResponseEntity getMentorMyPage( return ResponseEntity.ok(mentorMyPageResponse); } - @RequireRoleAccess(roles = Role.MENTOR) + @RequireRoleAccess(roles = {Role.MENTOR, Role.TEMP_MENTOR}) @PutMapping public ResponseEntity updateMentorMyPage( @AuthorizedUser long siteUserId, @@ -43,11 +45,13 @@ public ResponseEntity updateMentorMyPage( return ResponseEntity.ok().build(); } + @RequireRoleAccess(roles = {Role.MENTOR, Role.TEMP_MENTOR}) @PostMapping public ResponseEntity createMentorMyPage( @AuthorizedUser long siteUserId, @Valid @RequestBody MentorProfileCreateRequest request ) { + log.info("Creating mentor my page"); mentorMyPageService.createMentorMyPage(siteUserId, request); return ResponseEntity.ok().build(); } diff --git a/src/main/java/com/example/solidconnection/mentor/service/MentorApplicationService.java b/src/main/java/com/example/solidconnection/mentor/service/MentorApplicationService.java index 14eb74c99..2c79ad29b 100644 --- a/src/main/java/com/example/solidconnection/mentor/service/MentorApplicationService.java +++ b/src/main/java/com/example/solidconnection/mentor/service/MentorApplicationService.java @@ -8,6 +8,7 @@ import com.example.solidconnection.s3.domain.ImgType; import com.example.solidconnection.s3.dto.UploadedFileUrlResponse; import com.example.solidconnection.s3.service.S3Service; +import com.example.solidconnection.siteuser.domain.Role; import com.example.solidconnection.siteuser.domain.SiteUser; import com.example.solidconnection.siteuser.repository.SiteUserRepository; import java.util.List; @@ -55,5 +56,9 @@ public void submitMentorApplication( mentorApplicationRequest.exchangeStatus() ); mentorApplicationRepository.save(mentorApplication); + + if(siteUser.getRole() == Role.MENTEE){ + siteUser.changeRole(Role.TEMP_MENTOR); + } } } \ No newline at end of file diff --git a/src/main/java/com/example/solidconnection/mentor/service/MentorMyPageService.java b/src/main/java/com/example/solidconnection/mentor/service/MentorMyPageService.java index a60a45131..77fb055c3 100644 --- a/src/main/java/com/example/solidconnection/mentor/service/MentorMyPageService.java +++ b/src/main/java/com/example/solidconnection/mentor/service/MentorMyPageService.java @@ -27,9 +27,11 @@ import java.util.ArrayList; import java.util.List; import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +@Slf4j @RequiredArgsConstructor @Service public class MentorMyPageService { @@ -76,7 +78,9 @@ private void updateChannel(List channelRequests, Mentor mentor) mentor.updateChannels(newChannels); } + @Transactional public void createMentorMyPage(long siteUserId, MentorProfileCreateRequest request) { + log.info("Creating mentor my page for site user id {}", siteUserId); validateUserCanCreateMentor(siteUserId); validateChannelRegistrationLimit(request.channels()); MentorApplication mentorApplication = mentorApplicationRepository.findBySiteUserId(siteUserId) @@ -111,6 +115,7 @@ private void validateChannelRegistrationLimit(List channelReques } private void createChannels(List channelRequests, Mentor mentor) { + log.info("Channels creation"); int sequence = CHANNEL_SEQUENCE_START_NUMBER; List newChannels = new ArrayList<>(); for (ChannelRequest request : channelRequests) { diff --git a/src/main/java/com/example/solidconnection/siteuser/domain/SiteUser.java b/src/main/java/com/example/solidconnection/siteuser/domain/SiteUser.java index 30afc423e..a2ae467c1 100644 --- a/src/main/java/com/example/solidconnection/siteuser/domain/SiteUser.java +++ b/src/main/java/com/example/solidconnection/siteuser/domain/SiteUser.java @@ -120,4 +120,8 @@ public SiteUser( public void updatePassword(String newEncodedPassword) { this.password = newEncodedPassword; } + + public void changeRole(Role role){ + this.role = role; + } } From 9221ecd90a115d8b78b1a0a2c39957d77caaba76 Mon Sep 17 00:00:00 2001 From: sukangpunch Date: Tue, 4 Nov 2025 16:24:26 +0900 Subject: [PATCH 03/10] =?UTF-8?q?fix:=20MentorQueryService=EC=97=90?= =?UTF-8?q?=EC=84=9C=20=EB=A9=98=ED=86=A0=20=EC=A1=B0=ED=9A=8C=20=EC=8B=9C?= =?UTF-8?q?=20=EC=9E=84=EC=8B=9C=20=EB=A9=98=ED=86=A0=20=EC=A0=9C=EC=99=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: getMentorDetails 에서 Mentor 조회 후 비즈니스 로직으로 조회한 멘토에 대해 status 확인 후 임시멘토 제외 * fix: getMentorPreviews 에서 멘토 Slice 조회 시 jpa 메서드에 상태 기반 where 절을 추가하여 임시 멘토 제외 --- .../mentor/controller/MentorMyPageController.java | 2 +- .../example/solidconnection/mentor/domain/Mentor.java | 4 ++-- .../mentor/domain/MentorApplication.java | 6 +++--- .../solidconnection/mentor/domain/MentorStatus.java | 1 - .../mentor/repository/MentorRepository.java | 7 +++++-- .../mentor/service/MentorApplicationService.java | 8 +++++++- .../mentor/service/MentorMyPageService.java | 4 +--- .../mentor/service/MentorQueryService.java | 10 ++++++++-- .../term/repository/TermRepository.java | 2 ++ .../mentor/fixture/MentorApplicationFixture.java | 5 +++++ .../fixture/MentorApplicationFixtureBuilder.java | 9 +++++---- .../mentor/fixture/MentorFixtureBuilder.java | 6 +----- 12 files changed, 40 insertions(+), 24 deletions(-) diff --git a/src/main/java/com/example/solidconnection/mentor/controller/MentorMyPageController.java b/src/main/java/com/example/solidconnection/mentor/controller/MentorMyPageController.java index 42e30b1c6..b15f17d1e 100644 --- a/src/main/java/com/example/solidconnection/mentor/controller/MentorMyPageController.java +++ b/src/main/java/com/example/solidconnection/mentor/controller/MentorMyPageController.java @@ -26,7 +26,7 @@ public class MentorMyPageController { private final MentorMyPageService mentorMyPageService; - @RequireRoleAccess(roles = Role.MENTOR) + @RequireRoleAccess(roles = {Role.MENTOR, Role.TEMP_MENTOR}) @GetMapping public ResponseEntity getMentorMyPage( @AuthorizedUser long siteUserId diff --git a/src/main/java/com/example/solidconnection/mentor/domain/Mentor.java b/src/main/java/com/example/solidconnection/mentor/domain/Mentor.java index 38980f208..29b54ba75 100644 --- a/src/main/java/com/example/solidconnection/mentor/domain/Mentor.java +++ b/src/main/java/com/example/solidconnection/mentor/domain/Mentor.java @@ -64,13 +64,13 @@ public Mentor( String passTip, long siteUserId, Long universityId, - String term + long termId ) { this.introduction = introduction; this.passTip = passTip; this.siteUserId = siteUserId; this.universityId = universityId; - this.term = term; + this.termId = termId; this.mentorStatus = MentorStatus.TEMPORARY; } diff --git a/src/main/java/com/example/solidconnection/mentor/domain/MentorApplication.java b/src/main/java/com/example/solidconnection/mentor/domain/MentorApplication.java index d6ce71af7..aacd1e503 100644 --- a/src/main/java/com/example/solidconnection/mentor/domain/MentorApplication.java +++ b/src/main/java/com/example/solidconnection/mentor/domain/MentorApplication.java @@ -54,7 +54,7 @@ public class MentorApplication extends BaseEntity { private String mentorProofUrl; @Column(length = 50, nullable = false) - private String term; + private long termId; private String rejectedReason; @@ -75,7 +75,7 @@ public MentorApplication( Long universityId, UniversitySelectType universitySelectType, String mentorProofUrl, - String term, + long termId, ExchangeStatus exchangeStatus ) { validateExchangeStatus(exchangeStatus); @@ -86,7 +86,7 @@ public MentorApplication( this.universityId = universityId; this.universitySelectType = universitySelectType; this.mentorProofUrl = mentorProofUrl; - this.term = term; + this.termId = termId; this.exchangeStatus = exchangeStatus; } diff --git a/src/main/java/com/example/solidconnection/mentor/domain/MentorStatus.java b/src/main/java/com/example/solidconnection/mentor/domain/MentorStatus.java index 3b1cb6f30..57a704455 100644 --- a/src/main/java/com/example/solidconnection/mentor/domain/MentorStatus.java +++ b/src/main/java/com/example/solidconnection/mentor/domain/MentorStatus.java @@ -4,7 +4,6 @@ public enum MentorStatus { TEMPORARY, APPROVED, - REJECTED, ; } diff --git a/src/main/java/com/example/solidconnection/mentor/repository/MentorRepository.java b/src/main/java/com/example/solidconnection/mentor/repository/MentorRepository.java index 430602f1e..de14d1fb3 100644 --- a/src/main/java/com/example/solidconnection/mentor/repository/MentorRepository.java +++ b/src/main/java/com/example/solidconnection/mentor/repository/MentorRepository.java @@ -2,6 +2,8 @@ import com.example.solidconnection.location.region.domain.Region; import com.example.solidconnection.mentor.domain.Mentor; +import com.example.solidconnection.mentor.domain.MentorStatus; +import java.util.List; import java.util.Optional; import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Slice; @@ -15,12 +17,13 @@ public interface MentorRepository extends JpaRepository { Optional findBySiteUserId(long siteUserId); - Slice findAllBy(Pageable pageable); + Slice findAllByMentorStatus(MentorStatus mentorStatus, Pageable pageable); @Query(""" SELECT m FROM Mentor m JOIN University u ON m.universityId = u.id WHERE u.region = :region + AND m.mentorStatus = :mentorStatus """) - Slice findAllByRegion(@Param("region") Region region, Pageable pageable); + Slice findAllByRegionAndMentorStatus(@Param("region") Region region, @Param("mentorStatus") MentorStatus mentorStatus, Pageable pageable); } diff --git a/src/main/java/com/example/solidconnection/mentor/service/MentorApplicationService.java b/src/main/java/com/example/solidconnection/mentor/service/MentorApplicationService.java index 2c79ad29b..9c2b3e193 100644 --- a/src/main/java/com/example/solidconnection/mentor/service/MentorApplicationService.java +++ b/src/main/java/com/example/solidconnection/mentor/service/MentorApplicationService.java @@ -11,6 +11,8 @@ import com.example.solidconnection.siteuser.domain.Role; import com.example.solidconnection.siteuser.domain.SiteUser; import com.example.solidconnection.siteuser.repository.SiteUserRepository; +import com.example.solidconnection.term.domain.Term; +import com.example.solidconnection.term.repository.TermRepository; import java.util.List; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -19,6 +21,7 @@ import org.springframework.web.multipart.MultipartFile; import static com.example.solidconnection.common.exception.ErrorCode.MENTOR_APPLICATION_ALREADY_EXISTED; +import static com.example.solidconnection.common.exception.ErrorCode.TERM_NOT_FOUND; import static com.example.solidconnection.common.exception.ErrorCode.USER_NOT_FOUND; @Service @@ -27,6 +30,7 @@ public class MentorApplicationService { private final MentorApplicationRepository mentorApplicationRepository; + private final TermRepository termRepository; private final SiteUserRepository siteUserRepository; private final S3Service s3Service; @@ -45,6 +49,8 @@ public void submitMentorApplication( SiteUser siteUser = siteUserRepository.findById(siteUserId) .orElseThrow(() -> new CustomException(USER_NOT_FOUND)); + Term term = termRepository.findByName(mentorApplicationRequest.term()) + .orElseThrow(() -> new CustomException(TERM_NOT_FOUND)); UploadedFileUrlResponse uploadedFile = s3Service.uploadFile(file, ImgType.MENTOR_PROOF); MentorApplication mentorApplication = new MentorApplication( siteUser.getId(), @@ -52,7 +58,7 @@ public void submitMentorApplication( mentorApplicationRequest.universityId(), mentorApplicationRequest.universitySelectType(), uploadedFile.fileUrl(), - mentorApplicationRequest.term(), + term.getId(), mentorApplicationRequest.exchangeStatus() ); mentorApplicationRepository.save(mentorApplication); diff --git a/src/main/java/com/example/solidconnection/mentor/service/MentorMyPageService.java b/src/main/java/com/example/solidconnection/mentor/service/MentorMyPageService.java index 77fb055c3..4c9dc72c0 100644 --- a/src/main/java/com/example/solidconnection/mentor/service/MentorMyPageService.java +++ b/src/main/java/com/example/solidconnection/mentor/service/MentorMyPageService.java @@ -80,7 +80,6 @@ private void updateChannel(List channelRequests, Mentor mentor) @Transactional public void createMentorMyPage(long siteUserId, MentorProfileCreateRequest request) { - log.info("Creating mentor my page for site user id {}", siteUserId); validateUserCanCreateMentor(siteUserId); validateChannelRegistrationLimit(request.channels()); MentorApplication mentorApplication = mentorApplicationRepository.findBySiteUserId(siteUserId) @@ -91,7 +90,7 @@ public void createMentorMyPage(long siteUserId, MentorProfileCreateRequest reque request.passTip(), siteUserId, request.universityId(), - mentorApplication.getTerm() + mentorApplication.getTermId() ); createChannels(request.channels(), mentor); @@ -115,7 +114,6 @@ private void validateChannelRegistrationLimit(List channelReques } private void createChannels(List channelRequests, Mentor mentor) { - log.info("Channels creation"); int sequence = CHANNEL_SEQUENCE_START_NUMBER; List newChannels = new ArrayList<>(); for (ChannelRequest request : channelRequests) { diff --git a/src/main/java/com/example/solidconnection/mentor/service/MentorQueryService.java b/src/main/java/com/example/solidconnection/mentor/service/MentorQueryService.java index a66b8d45d..2e8553c40 100644 --- a/src/main/java/com/example/solidconnection/mentor/service/MentorQueryService.java +++ b/src/main/java/com/example/solidconnection/mentor/service/MentorQueryService.java @@ -10,6 +10,7 @@ import com.example.solidconnection.location.region.domain.Region; import com.example.solidconnection.location.region.repository.RegionRepository; import com.example.solidconnection.mentor.domain.Mentor; +import com.example.solidconnection.mentor.domain.MentorStatus; import com.example.solidconnection.mentor.dto.MentorDetailResponse; import com.example.solidconnection.mentor.dto.MentorPreviewResponse; import com.example.solidconnection.mentor.repository.MentorBatchQueryRepository; @@ -25,6 +26,7 @@ import java.util.List; import java.util.Map; import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Slice; import org.springframework.stereotype.Service; @@ -32,6 +34,7 @@ @RequiredArgsConstructor @Service +@Slf4j public class MentorQueryService { private final MentorRepository mentorRepository; @@ -46,6 +49,9 @@ public class MentorQueryService { public MentorDetailResponse getMentorDetails(long mentorId, long currentUserId) { Mentor mentor = mentorRepository.findById(mentorId) .orElseThrow(() -> new CustomException(MENTOR_NOT_FOUND)); + if(mentor.getMentorStatus() == MentorStatus.TEMPORARY){ + throw new CustomException(MENTOR_NOT_FOUND); + } University university = universityRepository.findById(mentor.getUniversityId()) .orElseThrow(() -> new CustomException(UNIVERSITY_NOT_FOUND)); SiteUser mentorUser = siteUserRepository.findById(mentor.getSiteUserId()) @@ -68,11 +74,11 @@ public SliceResponse getMentorPreviews(String regionKorea private Slice filterMentorsByRegion(String regionKoreanName, Pageable pageable) { if (regionKoreanName == null || regionKoreanName.isEmpty()) { - return mentorRepository.findAll(pageable); + return mentorRepository.findAllByMentorStatus(MentorStatus.APPROVED, pageable); } Region region = regionRepository.findByKoreanName(regionKoreanName) .orElseThrow(() -> new CustomException(ErrorCode.REGION_NOT_FOUND_BY_KOREAN_NAME)); - return mentorRepository.findAllByRegion(region, pageable); + return mentorRepository.findAllByRegionAndMentorStatus(region, MentorStatus.APPROVED, pageable); } private List buildMentorPreviewsWithBatchQuery(List mentors, long currentUserId) { diff --git a/src/main/java/com/example/solidconnection/term/repository/TermRepository.java b/src/main/java/com/example/solidconnection/term/repository/TermRepository.java index 7badf27cb..763137dc9 100644 --- a/src/main/java/com/example/solidconnection/term/repository/TermRepository.java +++ b/src/main/java/com/example/solidconnection/term/repository/TermRepository.java @@ -7,4 +7,6 @@ public interface TermRepository extends JpaRepository { Optional findByIsCurrentTrue(); + + Optional findByName(String name); } diff --git a/src/test/java/com/example/solidconnection/mentor/fixture/MentorApplicationFixture.java b/src/test/java/com/example/solidconnection/mentor/fixture/MentorApplicationFixture.java index 918db7ef4..ea9154882 100644 --- a/src/test/java/com/example/solidconnection/mentor/fixture/MentorApplicationFixture.java +++ b/src/test/java/com/example/solidconnection/mentor/fixture/MentorApplicationFixture.java @@ -4,6 +4,7 @@ import com.example.solidconnection.mentor.domain.MentorApplicationStatus; import com.example.solidconnection.mentor.domain.UniversitySelectType; import com.example.solidconnection.siteuser.domain.ExchangeStatus; +import com.example.solidconnection.term.fixture.TermFixture; import lombok.RequiredArgsConstructor; import org.springframework.boot.test.context.TestComponent; @@ -12,6 +13,7 @@ public class MentorApplicationFixture { private final MentorApplicationFixtureBuilder mentorApplicationFixtureBuilder; + private final TermFixture termFixture; private static final String DEFAULT_COUNTRY_CODE = "US"; private static final String DEFAULT_PROOF_URL = "/mentor-proof.pdf"; @@ -28,6 +30,7 @@ public class MentorApplicationFixture { .universityId(universityId) .universitySelectType(selectType) .mentorProofUrl(DEFAULT_PROOF_URL) + .termId(termFixture.현재_학기("2025-1").getId()) .exchangeStatus(DEFAULT_EXCHANGE_STATUS) .create(); } @@ -44,6 +47,7 @@ public class MentorApplicationFixture { .universitySelectType(selectType) .mentorProofUrl(DEFAULT_PROOF_URL) .exchangeStatus(DEFAULT_EXCHANGE_STATUS) + .termId(termFixture.현재_학기("2025-1").getId()) .mentorApplicationStatus(MentorApplicationStatus.APPROVED) .create(); } @@ -60,6 +64,7 @@ public class MentorApplicationFixture { .universitySelectType(selectType) .mentorProofUrl(DEFAULT_PROOF_URL) .exchangeStatus(DEFAULT_EXCHANGE_STATUS) + .termId(termFixture.현재_학기("2025-1").getId()) .mentorApplicationStatus(MentorApplicationStatus.REJECTED) .create(); } diff --git a/src/test/java/com/example/solidconnection/mentor/fixture/MentorApplicationFixtureBuilder.java b/src/test/java/com/example/solidconnection/mentor/fixture/MentorApplicationFixtureBuilder.java index 8344133b7..55dbaaa7f 100644 --- a/src/test/java/com/example/solidconnection/mentor/fixture/MentorApplicationFixtureBuilder.java +++ b/src/test/java/com/example/solidconnection/mentor/fixture/MentorApplicationFixtureBuilder.java @@ -5,6 +5,7 @@ import com.example.solidconnection.mentor.domain.UniversitySelectType; import com.example.solidconnection.mentor.repository.MentorApplicationRepository; import com.example.solidconnection.siteuser.domain.ExchangeStatus; +import com.example.solidconnection.term.domain.Term; import lombok.RequiredArgsConstructor; import org.springframework.boot.test.context.TestComponent; import org.springframework.test.util.ReflectionTestUtils; @@ -20,7 +21,7 @@ public class MentorApplicationFixtureBuilder { private Long universityId = null; private UniversitySelectType universitySelectType = UniversitySelectType.OTHER; private String mentorProofUrl = "/mentor-proof.pdf"; - private String term = "2025-1"; + private long termId; private ExchangeStatus exchangeStatus = ExchangeStatus.AFTER_EXCHANGE; private MentorApplicationStatus mentorApplicationStatus = MentorApplicationStatus.PENDING; @@ -53,8 +54,8 @@ public MentorApplicationFixtureBuilder mentorProofUrl(String mentorProofUrl) { return this; } - public MentorApplicationFixtureBuilder term(String term) { - this.term = term; + public MentorApplicationFixtureBuilder termId(long termId) { + this.termId = termId; return this; } @@ -75,7 +76,7 @@ public MentorApplication create() { universityId, universitySelectType, mentorProofUrl, - term, + termId, exchangeStatus ); ReflectionTestUtils.setField(mentorApplication, "mentorApplicationStatus", mentorApplicationStatus); diff --git a/src/test/java/com/example/solidconnection/mentor/fixture/MentorFixtureBuilder.java b/src/test/java/com/example/solidconnection/mentor/fixture/MentorFixtureBuilder.java index 12667bd22..4edafbb10 100644 --- a/src/test/java/com/example/solidconnection/mentor/fixture/MentorFixtureBuilder.java +++ b/src/test/java/com/example/solidconnection/mentor/fixture/MentorFixtureBuilder.java @@ -60,15 +60,11 @@ public MentorFixtureBuilder termId(long termId) { public Mentor create() { Mentor mentor = new Mentor( - null, - menteeCount, - hasBadge, introduction, passTip, siteUserId, universityId, - term, - null + termId ); return mentorRepository.save(mentor); } From 50e6dad7cbcd28fe8560f3e588b08e4f3136282d Mon Sep 17 00:00:00 2001 From: sukangpunch Date: Tue, 4 Nov 2025 17:58:23 +0900 Subject: [PATCH 04/10] =?UTF-8?q?refactor:=20submitMentorApplication=20?= =?UTF-8?q?=EB=A9=94=EC=84=9C=EB=93=9C=20=EB=A1=9C=EC=A7=81=EC=9D=84=20?= =?UTF-8?q?=EC=9D=98=EB=8F=84=EC=97=90=20=EB=A7=9E=EA=B2=8C=20=EB=B6=84?= =?UTF-8?q?=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * refactor: createMentorMyPage 에서 mentor 생성할 때, 대학 정보를 MentorApplication 에서 가져오게 수정 --- .../controller/MentorMyPageController.java | 5 ++--- .../solidconnection/mentor/domain/Mentor.java | 4 ++-- ...st.java => MentorMyPageCreateRequest.java} | 3 +-- .../service/MentorApplicationService.java | 21 +++++++++++++------ .../mentor/service/MentorMyPageService.java | 14 ++++++------- 5 files changed, 27 insertions(+), 20 deletions(-) rename src/main/java/com/example/solidconnection/mentor/dto/{MentorProfileCreateRequest.java => MentorMyPageCreateRequest.java} (85%) diff --git a/src/main/java/com/example/solidconnection/mentor/controller/MentorMyPageController.java b/src/main/java/com/example/solidconnection/mentor/controller/MentorMyPageController.java index b15f17d1e..b346f076d 100644 --- a/src/main/java/com/example/solidconnection/mentor/controller/MentorMyPageController.java +++ b/src/main/java/com/example/solidconnection/mentor/controller/MentorMyPageController.java @@ -3,7 +3,7 @@ import com.example.solidconnection.common.resolver.AuthorizedUser; import com.example.solidconnection.mentor.dto.MentorMyPageResponse; import com.example.solidconnection.mentor.dto.MentorMyPageUpdateRequest; -import com.example.solidconnection.mentor.dto.MentorProfileCreateRequest; +import com.example.solidconnection.mentor.dto.MentorMyPageCreateRequest; import com.example.solidconnection.mentor.service.MentorMyPageService; import com.example.solidconnection.security.annotation.RequireRoleAccess; import com.example.solidconnection.siteuser.domain.Role; @@ -49,9 +49,8 @@ public ResponseEntity updateMentorMyPage( @PostMapping public ResponseEntity createMentorMyPage( @AuthorizedUser long siteUserId, - @Valid @RequestBody MentorProfileCreateRequest request + @Valid @RequestBody MentorMyPageCreateRequest request ) { - log.info("Creating mentor my page"); mentorMyPageService.createMentorMyPage(siteUserId, request); return ResponseEntity.ok().build(); } diff --git a/src/main/java/com/example/solidconnection/mentor/domain/Mentor.java b/src/main/java/com/example/solidconnection/mentor/domain/Mentor.java index 29b54ba75..3f2511c87 100644 --- a/src/main/java/com/example/solidconnection/mentor/domain/Mentor.java +++ b/src/main/java/com/example/solidconnection/mentor/domain/Mentor.java @@ -35,10 +35,10 @@ public class Mentor extends BaseEntity { @Column private boolean hasBadge = false; - @Column(length = 1000, nullable = false) + @Column(length = 1000) private String introduction; - @Column(length = 1000, nullable = false) + @Column(length = 1000) private String passTip; @Column diff --git a/src/main/java/com/example/solidconnection/mentor/dto/MentorProfileCreateRequest.java b/src/main/java/com/example/solidconnection/mentor/dto/MentorMyPageCreateRequest.java similarity index 85% rename from src/main/java/com/example/solidconnection/mentor/dto/MentorProfileCreateRequest.java rename to src/main/java/com/example/solidconnection/mentor/dto/MentorMyPageCreateRequest.java index a34fc6a9a..5834465fd 100644 --- a/src/main/java/com/example/solidconnection/mentor/dto/MentorProfileCreateRequest.java +++ b/src/main/java/com/example/solidconnection/mentor/dto/MentorMyPageCreateRequest.java @@ -4,8 +4,7 @@ import jakarta.validation.constraints.NotBlank; import java.util.List; -public record MentorProfileCreateRequest( - Long universityId, +public record MentorMyPageCreateRequest( @NotBlank(message = "자기소개를 입력해주세요.") String introduction, diff --git a/src/main/java/com/example/solidconnection/mentor/service/MentorApplicationService.java b/src/main/java/com/example/solidconnection/mentor/service/MentorApplicationService.java index 9c2b3e193..901b35637 100644 --- a/src/main/java/com/example/solidconnection/mentor/service/MentorApplicationService.java +++ b/src/main/java/com/example/solidconnection/mentor/service/MentorApplicationService.java @@ -40,18 +40,14 @@ public void submitMentorApplication( MentorApplicationRequest mentorApplicationRequest, MultipartFile file ) { - if (mentorApplicationRepository.existsBySiteUserIdAndMentorApplicationStatusIn( - siteUserId, - List.of(MentorApplicationStatus.PENDING, MentorApplicationStatus.APPROVED)) - ) { - throw new CustomException(MENTOR_APPLICATION_ALREADY_EXISTED); - } + ensureNoPendingOrApprovedMentorApplication(siteUserId); SiteUser siteUser = siteUserRepository.findById(siteUserId) .orElseThrow(() -> new CustomException(USER_NOT_FOUND)); Term term = termRepository.findByName(mentorApplicationRequest.term()) .orElseThrow(() -> new CustomException(TERM_NOT_FOUND)); UploadedFileUrlResponse uploadedFile = s3Service.uploadFile(file, ImgType.MENTOR_PROOF); + MentorApplication mentorApplication = new MentorApplication( siteUser.getId(), mentorApplicationRequest.country(), @@ -63,6 +59,19 @@ public void submitMentorApplication( ); mentorApplicationRepository.save(mentorApplication); + promoteRoleMenteeToTempMentor(siteUser); + } + + private void ensureNoPendingOrApprovedMentorApplication(long siteUserId) { + if (mentorApplicationRepository.existsBySiteUserIdAndMentorApplicationStatusIn( + siteUserId, + List.of(MentorApplicationStatus.PENDING, MentorApplicationStatus.APPROVED)) + ) { + throw new CustomException(MENTOR_APPLICATION_ALREADY_EXISTED); + } + } + + private void promoteRoleMenteeToTempMentor(SiteUser siteUser) { if(siteUser.getRole() == Role.MENTEE){ siteUser.changeRole(Role.TEMP_MENTOR); } diff --git a/src/main/java/com/example/solidconnection/mentor/service/MentorMyPageService.java b/src/main/java/com/example/solidconnection/mentor/service/MentorMyPageService.java index 4c9dc72c0..b92326ab4 100644 --- a/src/main/java/com/example/solidconnection/mentor/service/MentorMyPageService.java +++ b/src/main/java/com/example/solidconnection/mentor/service/MentorMyPageService.java @@ -15,7 +15,7 @@ import com.example.solidconnection.mentor.dto.ChannelRequest; import com.example.solidconnection.mentor.dto.MentorMyPageResponse; import com.example.solidconnection.mentor.dto.MentorMyPageUpdateRequest; -import com.example.solidconnection.mentor.dto.MentorProfileCreateRequest; +import com.example.solidconnection.mentor.dto.MentorMyPageCreateRequest; import com.example.solidconnection.mentor.repository.MentorApplicationRepository; import com.example.solidconnection.mentor.repository.MentorRepository; import com.example.solidconnection.siteuser.domain.SiteUser; @@ -79,17 +79,17 @@ private void updateChannel(List channelRequests, Mentor mentor) } @Transactional - public void createMentorMyPage(long siteUserId, MentorProfileCreateRequest request) { + public void createMentorMyPage(long siteUserId, MentorMyPageCreateRequest request) { validateUserCanCreateMentor(siteUserId); validateChannelRegistrationLimit(request.channels()); MentorApplication mentorApplication = mentorApplicationRepository.findBySiteUserId(siteUserId) - .orElseThrow(()->new CustomException(MENTOR_APPLICATION_ALREADY_EXISTED)); + .orElseThrow(() -> new CustomException(MENTOR_APPLICATION_ALREADY_EXISTED)); Mentor mentor = new Mentor( request.introduction(), request.passTip(), siteUserId, - request.universityId(), + mentorApplication.getUniversityId(), mentorApplication.getTermId() ); @@ -97,12 +97,12 @@ public void createMentorMyPage(long siteUserId, MentorProfileCreateRequest reque mentorRepository.save(mentor); } - private void validateUserCanCreateMentor(long siteUserId){ - if(!siteUserRepository.existsById(siteUserId)) { + private void validateUserCanCreateMentor(long siteUserId) { + if (!siteUserRepository.existsById(siteUserId)) { throw new CustomException(USER_NOT_FOUND); } - if(mentorRepository.existsBySiteUserId(siteUserId)) { + if (mentorRepository.existsBySiteUserId(siteUserId)) { throw new CustomException(MENTOR_ALREADY_EXISTS); } } From 84c07eb11df887430cd6293aeb0d8a1f0f79c7af Mon Sep 17 00:00:00 2001 From: sukangpunch Date: Tue, 4 Nov 2025 20:21:46 +0900 Subject: [PATCH 05/10] =?UTF-8?q?test:=20MentorApplicationTest=EC=97=90?= =?UTF-8?q?=EC=84=9C=20=EB=A9=98=ED=86=A0=20=EC=8A=B9=EA=B2=A9=20=EC=9A=94?= =?UTF-8?q?=EC=B2=AD=20=EC=8B=9C=20ROLE=20=EC=9D=B4=20TEMP=5FMENTOR=20?= =?UTF-8?q?=EB=A1=9C=20=EB=B3=80=EA=B2=BD=EB=90=A8=EC=9D=84=20=ED=99=95?= =?UTF-8?q?=EC=9D=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/MentorApplicationServiceTest.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/test/java/com/example/solidconnection/mentor/service/MentorApplicationServiceTest.java b/src/test/java/com/example/solidconnection/mentor/service/MentorApplicationServiceTest.java index abebaf2a3..c7412a8f0 100644 --- a/src/test/java/com/example/solidconnection/mentor/service/MentorApplicationServiceTest.java +++ b/src/test/java/com/example/solidconnection/mentor/service/MentorApplicationServiceTest.java @@ -3,6 +3,7 @@ import static com.example.solidconnection.common.exception.ErrorCode.MENTOR_APPLICATION_ALREADY_EXISTED; import static com.example.solidconnection.common.exception.ErrorCode.UNIVERSITY_ID_MUST_BE_NULL_FOR_OTHER; import static com.example.solidconnection.common.exception.ErrorCode.UNIVERSITY_ID_REQUIRED_FOR_CATALOG; +import static com.example.solidconnection.common.exception.ErrorCode.USER_NOT_FOUND; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.AssertionsForClassTypes.assertThatCode; import static org.mockito.BDDMockito.given; @@ -17,9 +18,13 @@ import com.example.solidconnection.s3.dto.UploadedFileUrlResponse; import com.example.solidconnection.s3.service.S3Service; import com.example.solidconnection.siteuser.domain.ExchangeStatus; +import com.example.solidconnection.siteuser.domain.Role; import com.example.solidconnection.siteuser.domain.SiteUser; import com.example.solidconnection.siteuser.fixture.SiteUserFixture; +import com.example.solidconnection.siteuser.repository.SiteUserRepository; import com.example.solidconnection.support.TestContainerSpringBootTest; +import com.example.solidconnection.term.domain.Term; +import com.example.solidconnection.term.fixture.TermFixture; import java.util.List; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; @@ -38,9 +43,15 @@ public class MentorApplicationServiceTest { @Autowired private MentorApplicationRepository mentorApplicationRepository; + @Autowired + private SiteUserRepository siteUserRepository; + @Autowired private SiteUserFixture siteUserFixture; + @Autowired + private TermFixture termFixture; + @Autowired private MentorApplicationFixture mentorApplicationFixture; @@ -49,9 +60,12 @@ public class MentorApplicationServiceTest { private SiteUser user; + private Term term; + @BeforeEach void setUp() { user = siteUserFixture.사용자(); + term = termFixture.현재_학기("2025-1"); } @Test @@ -69,6 +83,7 @@ void setUp() { mentorApplicationService.submitMentorApplication(user.getId(), request, file); // then + assertThat(siteUserRepository.findById(user.getId()).get().getRole()).isEqualTo(Role.TEMP_MENTOR); assertThat(mentorApplicationRepository.existsBySiteUserIdAndMentorApplicationStatusIn(user.getId(), List.of(MentorApplicationStatus.PENDING, MentorApplicationStatus.APPROVED))).isEqualTo(true); } @@ -87,6 +102,7 @@ void setUp() { mentorApplicationService.submitMentorApplication(user.getId(), request, file); // then + assertThat(siteUserRepository.findById(user.getId()).get().getRole()).isEqualTo(Role.TEMP_MENTOR); assertThat(mentorApplicationRepository.existsBySiteUserIdAndMentorApplicationStatusIn(user.getId(),List.of(MentorApplicationStatus.PENDING, MentorApplicationStatus.APPROVED))).isEqualTo(true); } @@ -173,6 +189,7 @@ void setUp() { mentorApplicationService.submitMentorApplication(user.getId(), request, file); // then + assertThat(siteUserRepository.findById(user.getId()).get().getRole()).isEqualTo(Role.TEMP_MENTOR); assertThat(mentorApplicationRepository.existsBySiteUserIdAndMentorApplicationStatusIn(user.getId(),List.of(MentorApplicationStatus.PENDING, MentorApplicationStatus.APPROVED))).isEqualTo(true); } From e8f0c2d532fa5d24af34dcd3748bbac4d5d13b0f Mon Sep 17 00:00:00 2001 From: sukangpunch Date: Wed, 5 Nov 2025 01:08:23 +0900 Subject: [PATCH 06/10] =?UTF-8?q?test:=20MentorMyPageServiceTest,=20Mentor?= =?UTF-8?q?QueryServiceTest=20=EB=B3=80=EA=B2=BD=EC=82=AC=ED=95=AD=20?= =?UTF-8?q?=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * test: MentorFixture에 임시멘토 생성 메서드 추가 * test: MentorQueryService에서 임시 멘토는 조회 관련 테스트 추가 * test: MentorMyPageServiceTest 에서 멘토 마이페이지 생성 테스트 추가 --- .../solidconnection/mentor/domain/Mentor.java | 4 + .../mentor/service/MentorMyPageService.java | 3 +- .../mentor/fixture/MentorFixture.java | 10 +++ .../mentor/fixture/MentorFixtureBuilder.java | 12 +++ .../service/MentorApplicationServiceTest.java | 4 +- .../service/MentorMyPageServiceTest.java | 87 +++++++++++++++++++ .../service/MentorQueryServiceTest.java | 70 +++++++++++++++ .../siteuser/fixture/SiteUserFixture.java | 11 +++ 8 files changed, 197 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/example/solidconnection/mentor/domain/Mentor.java b/src/main/java/com/example/solidconnection/mentor/domain/Mentor.java index 3f2511c87..caae5b0ef 100644 --- a/src/main/java/com/example/solidconnection/mentor/domain/Mentor.java +++ b/src/main/java/com/example/solidconnection/mentor/domain/Mentor.java @@ -110,4 +110,8 @@ public void createChannels(List channels) { this.channels.add(channel); } } + + public void approve(){ + this.mentorStatus = MentorStatus.APPROVED; + } } diff --git a/src/main/java/com/example/solidconnection/mentor/service/MentorMyPageService.java b/src/main/java/com/example/solidconnection/mentor/service/MentorMyPageService.java index b92326ab4..d8c06abdc 100644 --- a/src/main/java/com/example/solidconnection/mentor/service/MentorMyPageService.java +++ b/src/main/java/com/example/solidconnection/mentor/service/MentorMyPageService.java @@ -3,6 +3,7 @@ import static com.example.solidconnection.common.exception.ErrorCode.CHANNEL_REGISTRATION_LIMIT_EXCEEDED; import static com.example.solidconnection.common.exception.ErrorCode.MENTOR_ALREADY_EXISTS; import static com.example.solidconnection.common.exception.ErrorCode.MENTOR_APPLICATION_ALREADY_EXISTED; +import static com.example.solidconnection.common.exception.ErrorCode.MENTOR_APPLICATION_NOT_FOUND; import static com.example.solidconnection.common.exception.ErrorCode.MENTOR_NOT_FOUND; import static com.example.solidconnection.common.exception.ErrorCode.TERM_NOT_FOUND; import static com.example.solidconnection.common.exception.ErrorCode.UNIVERSITY_NOT_FOUND; @@ -83,7 +84,7 @@ public void createMentorMyPage(long siteUserId, MentorMyPageCreateRequest reques validateUserCanCreateMentor(siteUserId); validateChannelRegistrationLimit(request.channels()); MentorApplication mentorApplication = mentorApplicationRepository.findBySiteUserId(siteUserId) - .orElseThrow(() -> new CustomException(MENTOR_APPLICATION_ALREADY_EXISTED)); + .orElseThrow(() -> new CustomException(MENTOR_APPLICATION_NOT_FOUND)); Mentor mentor = new Mentor( request.introduction(), diff --git a/src/test/java/com/example/solidconnection/mentor/fixture/MentorFixture.java b/src/test/java/com/example/solidconnection/mentor/fixture/MentorFixture.java index 8e47d11d1..e153631a1 100644 --- a/src/test/java/com/example/solidconnection/mentor/fixture/MentorFixture.java +++ b/src/test/java/com/example/solidconnection/mentor/fixture/MentorFixture.java @@ -21,4 +21,14 @@ public class MentorFixture { .termId(termFixture.현재_학기("2025-1").getId()) .create(); } + + public Mentor 임시멘토(long siteUserId, long universityId) { + return mentorFixtureBuilder.mentor() + .siteUserId(siteUserId) + .universityId(universityId) + .introduction("멘토 소개") + .passTip("합격 팁") + .termId(termFixture.현재_학기("2025-1").getId()) + .createTempMentor(); + } } diff --git a/src/test/java/com/example/solidconnection/mentor/fixture/MentorFixtureBuilder.java b/src/test/java/com/example/solidconnection/mentor/fixture/MentorFixtureBuilder.java index 4edafbb10..38deec62b 100644 --- a/src/test/java/com/example/solidconnection/mentor/fixture/MentorFixtureBuilder.java +++ b/src/test/java/com/example/solidconnection/mentor/fixture/MentorFixtureBuilder.java @@ -66,6 +66,18 @@ public Mentor create() { universityId, termId ); + mentor.approve(); return mentorRepository.save(mentor); } + + public Mentor createTempMentor(){ + Mentor tempMentor = new Mentor( + introduction, + passTip, + siteUserId, + universityId, + termId + ); + return mentorRepository.save(tempMentor); + } } diff --git a/src/test/java/com/example/solidconnection/mentor/service/MentorApplicationServiceTest.java b/src/test/java/com/example/solidconnection/mentor/service/MentorApplicationServiceTest.java index c7412a8f0..96bff3cfa 100644 --- a/src/test/java/com/example/solidconnection/mentor/service/MentorApplicationServiceTest.java +++ b/src/test/java/com/example/solidconnection/mentor/service/MentorApplicationServiceTest.java @@ -60,12 +60,10 @@ public class MentorApplicationServiceTest { private SiteUser user; - private Term term; - @BeforeEach void setUp() { user = siteUserFixture.사용자(); - term = termFixture.현재_학기("2025-1"); + termFixture.현재_학기("2025-1"); } @Test diff --git a/src/test/java/com/example/solidconnection/mentor/service/MentorMyPageServiceTest.java b/src/test/java/com/example/solidconnection/mentor/service/MentorMyPageServiceTest.java index 7beb2e4f0..5e30d3b8d 100644 --- a/src/test/java/com/example/solidconnection/mentor/service/MentorMyPageServiceTest.java +++ b/src/test/java/com/example/solidconnection/mentor/service/MentorMyPageServiceTest.java @@ -1,18 +1,29 @@ package com.example.solidconnection.mentor.service; +import static com.example.solidconnection.common.exception.ErrorCode.CHANNEL_REGISTRATION_LIMIT_EXCEEDED; +import static com.example.solidconnection.common.exception.ErrorCode.MENTOR_ALREADY_EXISTS; +import static com.example.solidconnection.common.exception.ErrorCode.MENTOR_APPLICATION_NOT_FOUND; import static com.example.solidconnection.mentor.domain.ChannelType.BLOG; +import static com.example.solidconnection.mentor.domain.ChannelType.BRUNCH; import static com.example.solidconnection.mentor.domain.ChannelType.INSTAGRAM; +import static com.example.solidconnection.mentor.domain.ChannelType.YOUTUBE; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.tuple; +import static org.assertj.core.api.AssertionsForClassTypes.assertThatCode; import static org.junit.jupiter.api.Assertions.assertAll; +import com.example.solidconnection.common.exception.CustomException; import com.example.solidconnection.mentor.domain.Channel; import com.example.solidconnection.mentor.domain.Mentor; +import com.example.solidconnection.mentor.domain.MentorStatus; +import com.example.solidconnection.mentor.domain.UniversitySelectType; import com.example.solidconnection.mentor.dto.ChannelRequest; import com.example.solidconnection.mentor.dto.ChannelResponse; +import com.example.solidconnection.mentor.dto.MentorMyPageCreateRequest; import com.example.solidconnection.mentor.dto.MentorMyPageResponse; import com.example.solidconnection.mentor.dto.MentorMyPageUpdateRequest; import com.example.solidconnection.mentor.fixture.ChannelFixture; +import com.example.solidconnection.mentor.fixture.MentorApplicationFixture; import com.example.solidconnection.mentor.fixture.MentorFixture; import com.example.solidconnection.mentor.repository.ChannelRepositoryForTest; import com.example.solidconnection.mentor.repository.MentorRepository; @@ -57,9 +68,13 @@ class MentorMyPageServiceTest { @Autowired private ChannelRepositoryForTest channelRepositoryForTest; + @Autowired + private MentorApplicationFixture mentorApplicationFixture; + private SiteUser mentorUser; private Mentor mentor; private University university; + private SiteUser tempMentorUser; @BeforeEach void setUp() { @@ -67,6 +82,7 @@ void setUp() { university = universityFixture.메이지_대학(); mentorUser = siteUserFixture.멘토(1, "멘토"); mentor = mentorFixture.멘토(mentorUser.getId(), university.getId()); + tempMentorUser = siteUserFixture.임시멘토(); } @Nested @@ -155,4 +171,75 @@ class 멘토의_마이_페이지를_수정한다 { ); } } + + @Nested + class 멘토의_마이페이지를_생성한다 { + + @Test + void 멘토_정보를_생성한다() { + // given + String introduction = "멘토 자기소개"; + String passTip = "멘토의 합격 팁"; + List channels = List.of( + new ChannelRequest(BLOG, "https://blog.com"), + new ChannelRequest(INSTAGRAM, "https://instagram.com"), + new ChannelRequest(YOUTUBE, "https://youtubr.com"), + new ChannelRequest(BRUNCH, "https://brunch.com") + ); + MentorMyPageCreateRequest request = new MentorMyPageCreateRequest(introduction, passTip, channels); + mentorApplicationFixture.대기중_멘토신청(tempMentorUser.getId(), UniversitySelectType.CATALOG, university.getId()); + + // when + mentorMyPageService.createMentorMyPage(tempMentorUser.getId(), request); + + // then + Mentor createTempMentor = mentorRepository.findById(tempMentorUser.getId()).get(); + assertAll( + () -> assertThat(createTempMentor.getIntroduction()).isEqualTo(introduction), + () -> assertThat(createTempMentor.getPassTip()).isEqualTo(passTip), + () -> assertThat(createTempMentor.getMentorStatus()).isEqualTo(MentorStatus.TEMPORARY) + ); + } + + @Test + void 이미_멘토_정보가_존재하는데_생성_요청_시_예외가_발생한다() { + // given + MentorMyPageCreateRequest request = new MentorMyPageCreateRequest("introduction", "passTip", List.of()); + mentorFixture.멘토(tempMentorUser.getId(), university.getId()); + + // when & then + assertThatCode(() -> mentorMyPageService.createMentorMyPage(tempMentorUser.getId(), request)) + .isInstanceOf(CustomException.class) + .hasMessage(MENTOR_ALREADY_EXISTS.getMessage()); + } + + @Test + void 채널을_제한_이상_생성하면_예외가_발생한다() { + // given + List newChannels = List.of( + new ChannelRequest(BLOG, "https://blog.com"), + new ChannelRequest(INSTAGRAM, "https://instagram.com"), + new ChannelRequest(YOUTUBE, "https://youtubr.com"), + new ChannelRequest(BRUNCH, "https://brunch.com"), + new ChannelRequest(BLOG, "https://blog.com") + ); + MentorMyPageCreateRequest request = new MentorMyPageCreateRequest("introduction", "passTip", newChannels); + + // when & then + assertThatCode(() -> mentorMyPageService.createMentorMyPage(tempMentorUser.getId(), request)) + .isInstanceOf(CustomException.class) + .hasMessage(CHANNEL_REGISTRATION_LIMIT_EXCEEDED.getMessage()); + } + + @Test + void 멘토_승격_요청_없이_멘토_정보_생성_시_예외가_발생한다() { + // given + MentorMyPageCreateRequest request = new MentorMyPageCreateRequest("introduction", "passTip", List.of()); + + // when & then + assertThatCode(() -> mentorMyPageService.createMentorMyPage(tempMentorUser.getId(), request)) + .isInstanceOf(CustomException.class) + .hasMessage(MENTOR_APPLICATION_NOT_FOUND.getMessage()); + } + } } diff --git a/src/test/java/com/example/solidconnection/mentor/service/MentorQueryServiceTest.java b/src/test/java/com/example/solidconnection/mentor/service/MentorQueryServiceTest.java index 8a4088845..7238693bc 100644 --- a/src/test/java/com/example/solidconnection/mentor/service/MentorQueryServiceTest.java +++ b/src/test/java/com/example/solidconnection/mentor/service/MentorQueryServiceTest.java @@ -125,6 +125,18 @@ class 멘토_단일_조회_실패 { .isInstanceOf(CustomException.class) .hasMessageContaining(ErrorCode.MENTOR_NOT_FOUND.getMessage()); } + + @Test + void 임시멘토를_조회하면_예외가_발생한다() { + // given + SiteUser tempMentorUser = siteUserFixture.임시멘토(); + Mentor tempMentor = mentorFixture.임시멘토(tempMentorUser.getId(), university.getId()); + + // when & then + assertThatCode(() -> mentorQueryService.getMentorDetails(tempMentor.getId(), siteUserFixture.사용자().getId())) + .isInstanceOf(CustomException.class) + .hasMessageContaining(ErrorCode.MENTOR_NOT_FOUND.getMessage()); + } } @Nested @@ -176,6 +188,38 @@ void setUp() { ); } + @Test + void 임시멘토는_미리보기_목록에서_제외된다() { + // given + SiteUser tempMentorUser = siteUserFixture.임시멘토(); + Mentor tempMentor = mentorFixture.임시멘토(tempMentorUser.getId(), university1.getId()); + Channel channel1 = channelFixture.채널(1, mentor1); + Channel channel2 = channelFixture.채널(2, mentor2); + + // when + SliceResponse response = mentorQueryService.getMentorPreviews("", currentUser.getId(), PageRequest.of(0, 10)); + + // then + Map mentorPreviewMap = response.content().stream() + .collect(Collectors.toMap(MentorPreviewResponse::id, Function.identity())); + MentorPreviewResponse mentor1Response = mentorPreviewMap.get(mentor1.getId()); + MentorPreviewResponse mentor2Response = mentorPreviewMap.get(mentor2.getId()); + assertThat(mentorPreviewMap.get(tempMentor.getId())).isNull(); + assertAll( + () -> assertThat(mentor1Response.nickname()).isEqualTo(mentorUser1.getNickname()), + () -> assertThat(mentor1Response.universityName()).isEqualTo(university1.getKoreanName()), + () -> assertThat(mentor1Response.country()).isEqualTo(university1.getCountry().getKoreanName()), + () -> assertThat(mentor1Response.channels()).extracting(ChannelResponse::url) + .containsOnly(channel1.getUrl()), + + () -> assertThat(mentor2Response.nickname()).isEqualTo(mentorUser2.getNickname()), + () -> assertThat(mentor2Response.universityName()).isEqualTo(university2.getKoreanName()), + () -> assertThat(mentor2Response.country()).isEqualTo(university2.getCountry().getKoreanName()), + () -> assertThat(mentor2Response.channels()).extracting(ChannelResponse::url) + .containsOnly(channel2.getUrl()) + ); + } + @Test void 다음_페이지_번호를_응답한다() { // given @@ -232,6 +276,32 @@ void setUp() { ); } + @Test + void 권역으로_멘토_목록을_필터링_할때_임시멘토는_제외된다() { + // when + University americaUniversity = universityFixture.네바다주립_대학_라스베이거스(); + SiteUser tempMentorUser = siteUserFixture.임시멘토(); + Mentor tempMentor = mentorFixture.임시멘토(tempMentorUser.getId(), americaUniversity.getId()); + + SliceResponse asiaFilteredResponse = mentorQueryService.getMentorPreviews( + asiaUniversity.getRegion().getKoreanName(), currentUser.getId(), PageRequest.of(0, 10)); + SliceResponse europeFilteredResponse = mentorQueryService.getMentorPreviews( + europeUniversity.getRegion().getKoreanName(), currentUser.getId(), PageRequest.of(0, 10)); + SliceResponse americaFilteredResponse = mentorQueryService.getMentorPreviews( + americaUniversity.getRegion().getKoreanName(), currentUser.getId(), PageRequest.of(0, 10)); + + // then + assertAll( + () -> assertThat(americaFilteredResponse.content()).isEmpty(), + () -> assertThat(asiaFilteredResponse.content()).hasSize(1) + .extracting(MentorPreviewResponse::id) + .containsExactly(asiaMentor.getId()), + () -> assertThat(europeFilteredResponse.content()).hasSize(1) + .extracting(MentorPreviewResponse::id) + .containsExactly(europeMentor.getId()) + ); + } + @Test void 권역을_지정하지_않으면_전체_멘토_목록을_조회한다() { // when diff --git a/src/test/java/com/example/solidconnection/siteuser/fixture/SiteUserFixture.java b/src/test/java/com/example/solidconnection/siteuser/fixture/SiteUserFixture.java index 9c2eb12bc..4e503aac2 100644 --- a/src/test/java/com/example/solidconnection/siteuser/fixture/SiteUserFixture.java +++ b/src/test/java/com/example/solidconnection/siteuser/fixture/SiteUserFixture.java @@ -77,4 +77,15 @@ public class SiteUserFixture { .password("admin123") .create(); } + + public SiteUser 임시멘토(){ + return siteUserFixtureBuilder.siteUser() + .email("temp-mentor@example.com") + .authType(AuthType.EMAIL) + .nickname("임시멘토") + .profileImageUrl("profileImageUrl") + .role(Role.TEMP_MENTOR) + .password("temp-mentor123") + .create(); + } } From f53454e7f934d4dc13fe09c969412219b1ac0686 Mon Sep 17 00:00:00 2001 From: sukangpunch Date: Wed, 5 Nov 2025 13:43:43 +0900 Subject: [PATCH 07/10] =?UTF-8?q?refactor:=20getMentorDetails=20=EC=97=90?= =?UTF-8?q?=EC=84=9C=20=EC=9E=84=EC=8B=9C=20=EB=A9=98=ED=86=A0=20=ED=95=84?= =?UTF-8?q?=ED=84=B0=EB=A7=81=EC=9D=84=20JPA=20=EB=A9=94=EC=84=9C=EB=93=9C?= =?UTF-8?q?=EB=A1=9C=20=EB=8C=80=EC=B2=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: mentorRepository에 findByIdAndMentorStatus 메서드 추가 --- .../mentor/repository/MentorRepository.java | 2 ++ .../solidconnection/mentor/service/MentorQueryService.java | 7 ++----- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/example/solidconnection/mentor/repository/MentorRepository.java b/src/main/java/com/example/solidconnection/mentor/repository/MentorRepository.java index de14d1fb3..9837c903e 100644 --- a/src/main/java/com/example/solidconnection/mentor/repository/MentorRepository.java +++ b/src/main/java/com/example/solidconnection/mentor/repository/MentorRepository.java @@ -17,6 +17,8 @@ public interface MentorRepository extends JpaRepository { Optional findBySiteUserId(long siteUserId); + Optional findByIdAndMentorStatus(long id, MentorStatus mentorStatus); + Slice findAllByMentorStatus(MentorStatus mentorStatus, Pageable pageable); @Query(""" diff --git a/src/main/java/com/example/solidconnection/mentor/service/MentorQueryService.java b/src/main/java/com/example/solidconnection/mentor/service/MentorQueryService.java index 2e8553c40..47127a218 100644 --- a/src/main/java/com/example/solidconnection/mentor/service/MentorQueryService.java +++ b/src/main/java/com/example/solidconnection/mentor/service/MentorQueryService.java @@ -47,11 +47,8 @@ public class MentorQueryService { @Transactional(readOnly = true) public MentorDetailResponse getMentorDetails(long mentorId, long currentUserId) { - Mentor mentor = mentorRepository.findById(mentorId) - .orElseThrow(() -> new CustomException(MENTOR_NOT_FOUND)); - if(mentor.getMentorStatus() == MentorStatus.TEMPORARY){ - throw new CustomException(MENTOR_NOT_FOUND); - } + Mentor mentor = mentorRepository.findByIdAndMentorStatus(mentorId, MentorStatus.APPROVED) + .orElseThrow(()-> new CustomException(MENTOR_NOT_FOUND)); University university = universityRepository.findById(mentor.getUniversityId()) .orElseThrow(() -> new CustomException(UNIVERSITY_NOT_FOUND)); SiteUser mentorUser = siteUserRepository.findById(mentor.getSiteUserId()) From 730956a8470372ab19682599fdb7e8c4ffca14e9 Mon Sep 17 00:00:00 2001 From: sukangpunch Date: Wed, 5 Nov 2025 15:38:32 +0900 Subject: [PATCH 08/10] =?UTF-8?q?feat:=20flyway=20=EC=8A=A4=ED=81=AC?= =?UTF-8?q?=EB=A6=BD=ED=8A=B8=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: Mentor 에 MentorStatus enum 필드 추가 * feat: Role 에 TEMP_MENTOR 추가 --- ...mentor_status_filed_and_temp_mentor_role.sql | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 src/main/resources/db/migration/V37__add_mentor_status_filed_and_temp_mentor_role.sql diff --git a/src/main/resources/db/migration/V37__add_mentor_status_filed_and_temp_mentor_role.sql b/src/main/resources/db/migration/V37__add_mentor_status_filed_and_temp_mentor_role.sql new file mode 100644 index 000000000..96bae04c3 --- /dev/null +++ b/src/main/resources/db/migration/V37__add_mentor_status_filed_and_temp_mentor_role.sql @@ -0,0 +1,17 @@ +-- Mentor 테이블에 MentorStatus 추가 +-- 1) mentor_status 컬럼 생성 (임시로 NULL 허용) +ALTER TABLE mentor + ADD COLUMN mentor_status ENUM('TEMPORARY','APPROVED') NULL; + +-- 2) 기존 행 모두 APPROVED로 백필 +UPDATE mentor +SET mentor_status = 'APPROVED' +WHERE mentor_status IS NULL; + +-- 3) NOT NULL + 기본값 TEMPORARY 로 고정 +ALTER TABLE mentor + MODIFY COLUMN mentor_status ENUM('TEMPORARY','APPROVED') NOT NULL DEFAULT 'TEMPORARY'; + +-- Role 에 TEMP_MENTOR 추가 +ALTER TABLE site_user + MODIFY COLUMN `role` ENUM('MENTEE','MENTOR','ADMIN','TEMP_MENTOR') NOT NULL; From 06434d09905bcbc935033eb7f3e6eec7456e51ae Mon Sep 17 00:00:00 2001 From: sukangpunch Date: Wed, 5 Nov 2025 16:48:41 +0900 Subject: [PATCH 09/10] =?UTF-8?q?style:=20code=20=EC=BB=A8=EB=B2=A4?= =?UTF-8?q?=EC=85=98=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/example/solidconnection/mentor/domain/Mentor.java | 2 +- .../example/solidconnection/mentor/domain/MentorStatus.java | 1 - .../solidconnection/mentor/domain/UniversitySelectType.java | 3 ++- .../mentor/dto/MentorMyPageCreateRequest.java | 1 - .../mentor/repository/MentorBatchQueryRepository.java | 2 +- .../solidconnection/mentor/service/MentorMyPageService.java | 3 +-- .../solidconnection/mentor/fixture/ChannelFixture.java | 2 +- .../mentor/fixture/ChannelFixtureBuilder.java | 2 +- .../mentor/fixture/MentorApplicationFixture.java | 2 +- .../mentor/fixture/MentorApplicationFixtureBuilder.java | 2 +- .../solidconnection/mentor/fixture/MentorFixture.java | 2 +- .../solidconnection/mentor/fixture/MentorFixtureBuilder.java | 2 +- .../solidconnection/mentor/fixture/MentoringFixture.java | 2 +- .../mentor/service/MentorApplicationServiceTest.java | 4 +--- .../mentor/service/MentorMyPageServiceTest.java | 2 +- .../mentor/service/MentorQueryServiceTest.java | 2 +- .../mentor/service/MentoringCheckServiceTest.java | 2 +- .../mentor/service/MentoringCommandServiceTest.java | 5 ++--- .../mentor/service/MentoringQueryServiceTest.java | 2 +- 19 files changed, 19 insertions(+), 24 deletions(-) diff --git a/src/main/java/com/example/solidconnection/mentor/domain/Mentor.java b/src/main/java/com/example/solidconnection/mentor/domain/Mentor.java index caae5b0ef..f93981db7 100644 --- a/src/main/java/com/example/solidconnection/mentor/domain/Mentor.java +++ b/src/main/java/com/example/solidconnection/mentor/domain/Mentor.java @@ -114,4 +114,4 @@ public void createChannels(List channels) { public void approve(){ this.mentorStatus = MentorStatus.APPROVED; } -} +} \ No newline at end of file diff --git a/src/main/java/com/example/solidconnection/mentor/domain/MentorStatus.java b/src/main/java/com/example/solidconnection/mentor/domain/MentorStatus.java index 57a704455..3891677c9 100644 --- a/src/main/java/com/example/solidconnection/mentor/domain/MentorStatus.java +++ b/src/main/java/com/example/solidconnection/mentor/domain/MentorStatus.java @@ -5,5 +5,4 @@ public enum MentorStatus { TEMPORARY, APPROVED, ; - } diff --git a/src/main/java/com/example/solidconnection/mentor/domain/UniversitySelectType.java b/src/main/java/com/example/solidconnection/mentor/domain/UniversitySelectType.java index 92c3622a1..4c958d14c 100644 --- a/src/main/java/com/example/solidconnection/mentor/domain/UniversitySelectType.java +++ b/src/main/java/com/example/solidconnection/mentor/domain/UniversitySelectType.java @@ -3,5 +3,6 @@ public enum UniversitySelectType { CATALOG, - OTHER + OTHER, + ; } diff --git a/src/main/java/com/example/solidconnection/mentor/dto/MentorMyPageCreateRequest.java b/src/main/java/com/example/solidconnection/mentor/dto/MentorMyPageCreateRequest.java index 5834465fd..723931084 100644 --- a/src/main/java/com/example/solidconnection/mentor/dto/MentorMyPageCreateRequest.java +++ b/src/main/java/com/example/solidconnection/mentor/dto/MentorMyPageCreateRequest.java @@ -5,7 +5,6 @@ import java.util.List; public record MentorMyPageCreateRequest( - @NotBlank(message = "자기소개를 입력해주세요.") String introduction, diff --git a/src/main/java/com/example/solidconnection/mentor/repository/MentorBatchQueryRepository.java b/src/main/java/com/example/solidconnection/mentor/repository/MentorBatchQueryRepository.java index 27d6a80d3..5ca1f22b7 100644 --- a/src/main/java/com/example/solidconnection/mentor/repository/MentorBatchQueryRepository.java +++ b/src/main/java/com/example/solidconnection/mentor/repository/MentorBatchQueryRepository.java @@ -90,4 +90,4 @@ public Map getTermIdToNameMap(List mentors) { return termRepository.findAllById(termIds).stream() .collect(Collectors.toMap(Term::getId, Term::getName)); } -} +} \ No newline at end of file diff --git a/src/main/java/com/example/solidconnection/mentor/service/MentorMyPageService.java b/src/main/java/com/example/solidconnection/mentor/service/MentorMyPageService.java index d8c06abdc..2e0a81a0e 100644 --- a/src/main/java/com/example/solidconnection/mentor/service/MentorMyPageService.java +++ b/src/main/java/com/example/solidconnection/mentor/service/MentorMyPageService.java @@ -2,7 +2,6 @@ import static com.example.solidconnection.common.exception.ErrorCode.CHANNEL_REGISTRATION_LIMIT_EXCEEDED; import static com.example.solidconnection.common.exception.ErrorCode.MENTOR_ALREADY_EXISTS; -import static com.example.solidconnection.common.exception.ErrorCode.MENTOR_APPLICATION_ALREADY_EXISTED; import static com.example.solidconnection.common.exception.ErrorCode.MENTOR_APPLICATION_NOT_FOUND; import static com.example.solidconnection.common.exception.ErrorCode.MENTOR_NOT_FOUND; import static com.example.solidconnection.common.exception.ErrorCode.TERM_NOT_FOUND; @@ -122,4 +121,4 @@ private void createChannels(List channelRequests, Mentor mentor) } mentor.createChannels(newChannels); } -} +} \ No newline at end of file diff --git a/src/test/java/com/example/solidconnection/mentor/fixture/ChannelFixture.java b/src/test/java/com/example/solidconnection/mentor/fixture/ChannelFixture.java index d3c27c114..040268cda 100644 --- a/src/test/java/com/example/solidconnection/mentor/fixture/ChannelFixture.java +++ b/src/test/java/com/example/solidconnection/mentor/fixture/ChannelFixture.java @@ -20,4 +20,4 @@ public class ChannelFixture { .mentor(mentor) .create(); } -} +} \ No newline at end of file diff --git a/src/test/java/com/example/solidconnection/mentor/fixture/ChannelFixtureBuilder.java b/src/test/java/com/example/solidconnection/mentor/fixture/ChannelFixtureBuilder.java index 670b0e8b4..907ca0c8d 100644 --- a/src/test/java/com/example/solidconnection/mentor/fixture/ChannelFixtureBuilder.java +++ b/src/test/java/com/example/solidconnection/mentor/fixture/ChannelFixtureBuilder.java @@ -53,4 +53,4 @@ public Channel create() { channel.updateMentor(mentor); return channelRepository.save(channel); } -} +} \ No newline at end of file diff --git a/src/test/java/com/example/solidconnection/mentor/fixture/MentorApplicationFixture.java b/src/test/java/com/example/solidconnection/mentor/fixture/MentorApplicationFixture.java index ea9154882..4a830e494 100644 --- a/src/test/java/com/example/solidconnection/mentor/fixture/MentorApplicationFixture.java +++ b/src/test/java/com/example/solidconnection/mentor/fixture/MentorApplicationFixture.java @@ -68,4 +68,4 @@ public class MentorApplicationFixture { .mentorApplicationStatus(MentorApplicationStatus.REJECTED) .create(); } -} +} \ No newline at end of file diff --git a/src/test/java/com/example/solidconnection/mentor/fixture/MentorApplicationFixtureBuilder.java b/src/test/java/com/example/solidconnection/mentor/fixture/MentorApplicationFixtureBuilder.java index 55dbaaa7f..bbd2503e1 100644 --- a/src/test/java/com/example/solidconnection/mentor/fixture/MentorApplicationFixtureBuilder.java +++ b/src/test/java/com/example/solidconnection/mentor/fixture/MentorApplicationFixtureBuilder.java @@ -82,4 +82,4 @@ public MentorApplication create() { ReflectionTestUtils.setField(mentorApplication, "mentorApplicationStatus", mentorApplicationStatus); return mentorApplicationRepository.save(mentorApplication); } -} +} \ No newline at end of file diff --git a/src/test/java/com/example/solidconnection/mentor/fixture/MentorFixture.java b/src/test/java/com/example/solidconnection/mentor/fixture/MentorFixture.java index e153631a1..7b4a18f6b 100644 --- a/src/test/java/com/example/solidconnection/mentor/fixture/MentorFixture.java +++ b/src/test/java/com/example/solidconnection/mentor/fixture/MentorFixture.java @@ -31,4 +31,4 @@ public class MentorFixture { .termId(termFixture.현재_학기("2025-1").getId()) .createTempMentor(); } -} +} \ No newline at end of file diff --git a/src/test/java/com/example/solidconnection/mentor/fixture/MentorFixtureBuilder.java b/src/test/java/com/example/solidconnection/mentor/fixture/MentorFixtureBuilder.java index 38deec62b..2bfe79d3a 100644 --- a/src/test/java/com/example/solidconnection/mentor/fixture/MentorFixtureBuilder.java +++ b/src/test/java/com/example/solidconnection/mentor/fixture/MentorFixtureBuilder.java @@ -80,4 +80,4 @@ public Mentor createTempMentor(){ ); return mentorRepository.save(tempMentor); } -} +} \ No newline at end of file diff --git a/src/test/java/com/example/solidconnection/mentor/fixture/MentoringFixture.java b/src/test/java/com/example/solidconnection/mentor/fixture/MentoringFixture.java index 4779c643e..6a2d39d2e 100644 --- a/src/test/java/com/example/solidconnection/mentor/fixture/MentoringFixture.java +++ b/src/test/java/com/example/solidconnection/mentor/fixture/MentoringFixture.java @@ -55,4 +55,4 @@ public class MentoringFixture { private ZonedDateTime getCurrentTime() { return ZonedDateTime.now(UTC).truncatedTo(MICROS); } -} +} \ No newline at end of file diff --git a/src/test/java/com/example/solidconnection/mentor/service/MentorApplicationServiceTest.java b/src/test/java/com/example/solidconnection/mentor/service/MentorApplicationServiceTest.java index 96bff3cfa..412308ac9 100644 --- a/src/test/java/com/example/solidconnection/mentor/service/MentorApplicationServiceTest.java +++ b/src/test/java/com/example/solidconnection/mentor/service/MentorApplicationServiceTest.java @@ -3,7 +3,6 @@ import static com.example.solidconnection.common.exception.ErrorCode.MENTOR_APPLICATION_ALREADY_EXISTED; import static com.example.solidconnection.common.exception.ErrorCode.UNIVERSITY_ID_MUST_BE_NULL_FOR_OTHER; import static com.example.solidconnection.common.exception.ErrorCode.UNIVERSITY_ID_REQUIRED_FOR_CATALOG; -import static com.example.solidconnection.common.exception.ErrorCode.USER_NOT_FOUND; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.AssertionsForClassTypes.assertThatCode; import static org.mockito.BDDMockito.given; @@ -23,7 +22,6 @@ import com.example.solidconnection.siteuser.fixture.SiteUserFixture; import com.example.solidconnection.siteuser.repository.SiteUserRepository; import com.example.solidconnection.support.TestContainerSpringBootTest; -import com.example.solidconnection.term.domain.Term; import com.example.solidconnection.term.fixture.TermFixture; import java.util.List; import org.junit.jupiter.api.BeforeEach; @@ -209,4 +207,4 @@ private MentorApplicationRequest createMentorApplicationRequest(UniversitySelect "2025-1" ); } -} +} \ No newline at end of file diff --git a/src/test/java/com/example/solidconnection/mentor/service/MentorMyPageServiceTest.java b/src/test/java/com/example/solidconnection/mentor/service/MentorMyPageServiceTest.java index 5e30d3b8d..9abeeb8f8 100644 --- a/src/test/java/com/example/solidconnection/mentor/service/MentorMyPageServiceTest.java +++ b/src/test/java/com/example/solidconnection/mentor/service/MentorMyPageServiceTest.java @@ -242,4 +242,4 @@ class 멘토의_마이페이지를_생성한다 { .hasMessage(MENTOR_APPLICATION_NOT_FOUND.getMessage()); } } -} +} \ No newline at end of file diff --git a/src/test/java/com/example/solidconnection/mentor/service/MentorQueryServiceTest.java b/src/test/java/com/example/solidconnection/mentor/service/MentorQueryServiceTest.java index 7238693bc..5b6cde38d 100644 --- a/src/test/java/com/example/solidconnection/mentor/service/MentorQueryServiceTest.java +++ b/src/test/java/com/example/solidconnection/mentor/service/MentorQueryServiceTest.java @@ -313,4 +313,4 @@ void setUp() { .containsExactlyInAnyOrder(asiaMentor.getId(), europeMentor.getId()); } } -} +} \ No newline at end of file diff --git a/src/test/java/com/example/solidconnection/mentor/service/MentoringCheckServiceTest.java b/src/test/java/com/example/solidconnection/mentor/service/MentoringCheckServiceTest.java index c5f8a9463..c572ef34d 100644 --- a/src/test/java/com/example/solidconnection/mentor/service/MentoringCheckServiceTest.java +++ b/src/test/java/com/example/solidconnection/mentor/service/MentoringCheckServiceTest.java @@ -168,4 +168,4 @@ class 멘토가_확인하지_않은_멘토링_개수_조회_테스트 { } } } -} +} \ No newline at end of file diff --git a/src/test/java/com/example/solidconnection/mentor/service/MentoringCommandServiceTest.java b/src/test/java/com/example/solidconnection/mentor/service/MentoringCommandServiceTest.java index 8c6a78468..6d192137d 100644 --- a/src/test/java/com/example/solidconnection/mentor/service/MentoringCommandServiceTest.java +++ b/src/test/java/com/example/solidconnection/mentor/service/MentoringCommandServiceTest.java @@ -6,7 +6,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.junit.jupiter.api.Assertions.assertAll; -import static org.awaitility.Awaitility.await; + import com.example.solidconnection.chat.domain.ChatParticipant; import com.example.solidconnection.chat.domain.ChatRoom; import com.example.solidconnection.chat.repository.ChatRoomRepositoryForTest; @@ -25,7 +25,6 @@ import com.example.solidconnection.siteuser.domain.SiteUser; import com.example.solidconnection.siteuser.fixture.SiteUserFixture; import com.example.solidconnection.support.TestContainerSpringBootTest; -import java.time.Duration; import java.util.List; import java.util.Optional; import org.junit.jupiter.api.BeforeEach; @@ -226,4 +225,4 @@ class 멘토링_승인_거절_테스트 { .hasMessage(MENTORING_NOT_FOUND.getMessage()); } } -} +} \ No newline at end of file diff --git a/src/test/java/com/example/solidconnection/mentor/service/MentoringQueryServiceTest.java b/src/test/java/com/example/solidconnection/mentor/service/MentoringQueryServiceTest.java index cb680b986..7effd9687 100644 --- a/src/test/java/com/example/solidconnection/mentor/service/MentoringQueryServiceTest.java +++ b/src/test/java/com/example/solidconnection/mentor/service/MentoringQueryServiceTest.java @@ -324,4 +324,4 @@ void setUp() { assertThat(response.nextPageNumber()).isEqualTo(NO_NEXT_PAGE_NUMBER); } } -} +} \ No newline at end of file From 6ee3bbda4fe061eab928aec1ffa355227f6ffb38 Mon Sep 17 00:00:00 2001 From: sukangpunch Date: Wed, 5 Nov 2025 19:44:38 +0900 Subject: [PATCH 10/10] =?UTF-8?q?fix:=20=EC=BD=94=EB=93=9C=EB=9E=98?= =?UTF-8?q?=EB=B9=97=20=EB=A6=AC=EB=B7=B0=EC=82=AC=ED=95=AD=20=EC=A0=81?= =?UTF-8?q?=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * refactor: 채널 생성 로직 중복 제거 * fix: 사용하지 않는 NewsStatus 제거 * fix: MentorMyPageServiceTest 에서 siteUserId 를 mentorId 처럼 사용하는 문제 수정 --- .../mentor/service/MentorMyPageService.java | 13 +++++++------ .../solidconnection/news/domain/NewsStatus.java | 8 -------- .../mentor/service/MentorMyPageServiceTest.java | 2 +- 3 files changed, 8 insertions(+), 15 deletions(-) delete mode 100644 src/main/java/com/example/solidconnection/news/domain/NewsStatus.java diff --git a/src/main/java/com/example/solidconnection/mentor/service/MentorMyPageService.java b/src/main/java/com/example/solidconnection/mentor/service/MentorMyPageService.java index 2e0a81a0e..99eceed72 100644 --- a/src/main/java/com/example/solidconnection/mentor/service/MentorMyPageService.java +++ b/src/main/java/com/example/solidconnection/mentor/service/MentorMyPageService.java @@ -70,11 +70,7 @@ public void updateMentorMyPage(long siteUserId, MentorMyPageUpdateRequest reques } private void updateChannel(List channelRequests, Mentor mentor) { - int sequence = CHANNEL_SEQUENCE_START_NUMBER; - List newChannels = new ArrayList<>(); - for (ChannelRequest request : channelRequests) { - newChannels.add(new Channel(sequence++, request.type(), request.url())); - } + List newChannels = buildChannels(channelRequests); mentor.updateChannels(newChannels); } @@ -114,11 +110,16 @@ private void validateChannelRegistrationLimit(List channelReques } private void createChannels(List channelRequests, Mentor mentor) { + List newChannels = buildChannels(channelRequests); + mentor.createChannels(newChannels); + } + + private List buildChannels(List channelRequests) { int sequence = CHANNEL_SEQUENCE_START_NUMBER; List newChannels = new ArrayList<>(); for (ChannelRequest request : channelRequests) { newChannels.add(new Channel(sequence++, request.type(), request.url())); } - mentor.createChannels(newChannels); + return newChannels; } } \ No newline at end of file diff --git a/src/main/java/com/example/solidconnection/news/domain/NewsStatus.java b/src/main/java/com/example/solidconnection/news/domain/NewsStatus.java deleted file mode 100644 index ee5840035..000000000 --- a/src/main/java/com/example/solidconnection/news/domain/NewsStatus.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.example.solidconnection.news.domain; - -public enum NewsStatus { - - TEMPORARY, - APPROVED, - ; -} diff --git a/src/test/java/com/example/solidconnection/mentor/service/MentorMyPageServiceTest.java b/src/test/java/com/example/solidconnection/mentor/service/MentorMyPageServiceTest.java index 9abeeb8f8..2278f77d7 100644 --- a/src/test/java/com/example/solidconnection/mentor/service/MentorMyPageServiceTest.java +++ b/src/test/java/com/example/solidconnection/mentor/service/MentorMyPageServiceTest.java @@ -193,7 +193,7 @@ class 멘토의_마이페이지를_생성한다 { mentorMyPageService.createMentorMyPage(tempMentorUser.getId(), request); // then - Mentor createTempMentor = mentorRepository.findById(tempMentorUser.getId()).get(); + Mentor createTempMentor = mentorRepository.findBySiteUserId(tempMentorUser.getId()).get(); assertAll( () -> assertThat(createTempMentor.getIntroduction()).isEqualTo(introduction), () -> assertThat(createTempMentor.getPassTip()).isEqualTo(passTip),