From b64781d7857ea3c093b70e642631e03109289366 Mon Sep 17 00:00:00 2001 From: nayonsoso Date: Thu, 3 Jul 2025 03:09:11 +0900 Subject: [PATCH 01/24] =?UTF-8?q?feat:=20=EB=A9=98=ED=86=A0=20=EB=AF=B8?= =?UTF-8?q?=EB=A6=AC=EB=B3=B4=EA=B8=B0=20=EB=AA=A9=EB=A1=9D=20=EC=A1=B0?= =?UTF-8?q?=ED=9A=8C=20dto=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mentor/dto/MentorPreviewsResponse.java | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 src/main/java/com/example/solidconnection/mentor/dto/MentorPreviewsResponse.java diff --git a/src/main/java/com/example/solidconnection/mentor/dto/MentorPreviewsResponse.java b/src/main/java/com/example/solidconnection/mentor/dto/MentorPreviewsResponse.java new file mode 100644 index 000000000..cb49ba602 --- /dev/null +++ b/src/main/java/com/example/solidconnection/mentor/dto/MentorPreviewsResponse.java @@ -0,0 +1,9 @@ +package com.example.solidconnection.mentor.dto; + +import java.util.List; + +public record MentorPreviewsResponse( + List content, + int nextPageNumber +) { +} From 05b2db7332d24e8c09a4abbaf39c8cbcda5055b2 Mon Sep 17 00:00:00 2001 From: nayonsoso Date: Thu, 3 Jul 2025 03:16:31 +0900 Subject: [PATCH 02/24] =?UTF-8?q?feat:=20=EB=A9=98=ED=86=A0=20=EB=AF=B8?= =?UTF-8?q?=EB=A6=AC=EB=B3=B4=EA=B8=B0=20=EB=AA=A9=EB=A1=9D=20=EC=84=9C?= =?UTF-8?q?=EB=B9=84=EC=8A=A4=20=ED=95=A8=EC=88=98=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../solidconnection/mentor/service/MentorQueryService.java | 5 +++++ 1 file changed, 5 insertions(+) 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 a7c46e285..e3d95fb0f 100644 --- a/src/main/java/com/example/solidconnection/mentor/service/MentorQueryService.java +++ b/src/main/java/com/example/solidconnection/mentor/service/MentorQueryService.java @@ -6,6 +6,9 @@ import com.example.solidconnection.mentor.dto.MentorDetailResponse; import com.example.solidconnection.mentor.dto.MentorPreviewResponse; import com.example.solidconnection.mentor.repository.MentorBatchQueryRepository; +import com.example.solidconnection.mentor.dto.MentorPreviewResponse; +import com.example.solidconnection.mentor.dto.MentorPreviewsResponse; +import com.example.solidconnection.mentor.repository.MentorBatchQueryRepository; import com.example.solidconnection.mentor.repository.MentorRepository; import com.example.solidconnection.mentor.repository.MentoringRepository; import com.example.solidconnection.siteuser.domain.SiteUser; @@ -13,6 +16,8 @@ import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Slice; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; From e75413ecbe059cc21e6a59c7401db7e2ef29b21c Mon Sep 17 00:00:00 2001 From: nayonsoso Date: Thu, 3 Jul 2025 03:30:54 +0900 Subject: [PATCH 03/24] =?UTF-8?q?feat:=20=EB=A9=98=ED=86=A0=20=EB=AF=B8?= =?UTF-8?q?=EB=A6=AC=EB=B3=B4=EA=B8=B0=20=EB=AA=A9=EB=A1=9D=20=EC=BB=A8?= =?UTF-8?q?=ED=8A=B8=EB=A1=A4=EB=9F=AC=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../solidconnection/mentor/controller/MentorController.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/com/example/solidconnection/mentor/controller/MentorController.java b/src/main/java/com/example/solidconnection/mentor/controller/MentorController.java index ea60b180c..9c04c6a47 100644 --- a/src/main/java/com/example/solidconnection/mentor/controller/MentorController.java +++ b/src/main/java/com/example/solidconnection/mentor/controller/MentorController.java @@ -3,11 +3,14 @@ import com.example.solidconnection.common.dto.SliceResponse; import com.example.solidconnection.common.resolver.AuthorizedUser; import com.example.solidconnection.mentor.dto.MentorDetailResponse; +import com.example.solidconnection.mentor.dto.MentorPreviewsResponse; import com.example.solidconnection.mentor.dto.MentorPreviewResponse; import com.example.solidconnection.mentor.service.MentorQueryService; import com.example.solidconnection.siteuser.domain.SiteUser; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Pageable; +import org.springframework.data.web.PageableDefault; +import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Sort; import org.springframework.data.web.PageableDefault; import org.springframework.data.web.SortDefault; From d0714354bd75ad6b948da0d6f75c1faca84a13a1 Mon Sep 17 00:00:00 2001 From: nayonsoso Date: Sun, 6 Jul 2025 00:25:59 +0900 Subject: [PATCH 04/24] =?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=9D=91=EB=8B=B5=20dto?= =?UTF-8?q?=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mentor/dto/MentorMyPageResponse.java | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 src/main/java/com/example/solidconnection/mentor/dto/MentorMyPageResponse.java diff --git a/src/main/java/com/example/solidconnection/mentor/dto/MentorMyPageResponse.java b/src/main/java/com/example/solidconnection/mentor/dto/MentorMyPageResponse.java new file mode 100644 index 000000000..91077051f --- /dev/null +++ b/src/main/java/com/example/solidconnection/mentor/dto/MentorMyPageResponse.java @@ -0,0 +1,38 @@ +package com.example.solidconnection.mentor.dto; + +import com.example.solidconnection.mentor.domain.Mentor; +import com.example.solidconnection.siteuser.domain.ExchangeStatus; +import com.example.solidconnection.siteuser.domain.SiteUser; + +import java.util.List; + +public record MentorMyPageResponse( + long id, + String profileImageUrl, + String nickname, + ExchangeStatus exchangeStatus, + String country, + String universityName, + int menteeCount, + boolean hasBadge, + String introduction, + List channels +) { + + public static MentorMyPageResponse of(Mentor mentor, SiteUser siteUser) { + return new MentorMyPageResponse( + mentor.getId(), + siteUser.getProfileImageUrl(), + siteUser.getNickname(), + siteUser.getExchangeStatus(), + "국가", // todo: 교환학생 기록이 인증되면 추가 + "대학 이름", + mentor.getMenteeCount(), + mentor.isHasBadge(), + mentor.getIntroduction(), + mentor.getChannels().stream() + .map(ChannelResponse::from) + .toList() + ); + } +} From d67a23aac2a50771dbe2c23dbf7b8742391ce403 Mon Sep 17 00:00:00 2001 From: nayonsoso Date: Sun, 6 Jul 2025 00:26:39 +0900 Subject: [PATCH 05/24] =?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=9D=91=EB=8B=B5=20?= =?UTF-8?q?=EC=84=9C=EB=B9=84=EC=8A=A4=20=ED=95=A8=EC=88=98=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mentor/service/MentorMyPageService.java | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 src/main/java/com/example/solidconnection/mentor/service/MentorMyPageService.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 new file mode 100644 index 000000000..199415576 --- /dev/null +++ b/src/main/java/com/example/solidconnection/mentor/service/MentorMyPageService.java @@ -0,0 +1,26 @@ +package com.example.solidconnection.mentor.service; + +import com.example.solidconnection.common.exception.CustomException; +import com.example.solidconnection.mentor.domain.Mentor; +import com.example.solidconnection.mentor.dto.MentorMyPageResponse; +import com.example.solidconnection.mentor.repository.MentorRepository; +import com.example.solidconnection.siteuser.domain.SiteUser; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import static com.example.solidconnection.common.exception.ErrorCode.MENTOR_NOT_FOUND; + +@RequiredArgsConstructor +@Service +public class MentorMyPageService { + + private final MentorRepository mentorRepository; + + @Transactional(readOnly = true) + public MentorMyPageResponse getMentorMyPage(SiteUser siteUser) { + Mentor mentor = mentorRepository.findBySiteUserId(siteUser.getId()) + .orElseThrow(() -> new CustomException(MENTOR_NOT_FOUND)); + return MentorMyPageResponse.of(mentor, siteUser); + } +} From 2d84180a8928f47a1fce72de4d814aca0835ceb0 Mon Sep 17 00:00:00 2001 From: nayonsoso Date: Sun, 6 Jul 2025 00:26:52 +0900 Subject: [PATCH 06/24] =?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=BB=A8=ED=8A=B8?= =?UTF-8?q?=EB=A1=A4=EB=9F=AC=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/MentorMyPageController.java | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 src/main/java/com/example/solidconnection/mentor/controller/MentorMyPageController.java diff --git a/src/main/java/com/example/solidconnection/mentor/controller/MentorMyPageController.java b/src/main/java/com/example/solidconnection/mentor/controller/MentorMyPageController.java new file mode 100644 index 000000000..5240c7259 --- /dev/null +++ b/src/main/java/com/example/solidconnection/mentor/controller/MentorMyPageController.java @@ -0,0 +1,30 @@ +package com.example.solidconnection.mentor.controller; + +import com.example.solidconnection.common.resolver.AuthorizedUser; +import com.example.solidconnection.mentor.dto.MentorMyPageResponse; +import com.example.solidconnection.mentor.service.MentorMyPageService; +import com.example.solidconnection.security.annotation.RequireRoleAccess; +import com.example.solidconnection.siteuser.domain.Role; +import com.example.solidconnection.siteuser.domain.SiteUser; +import lombok.RequiredArgsConstructor; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RequiredArgsConstructor +@RequestMapping("/mentor/my") +@RestController +public class MentorMyPageController { + + private final MentorMyPageService mentorMyPageService; + + @RequireRoleAccess(roles = {Role.MENTOR}) + @GetMapping + public ResponseEntity getMentorMyPage( + @AuthorizedUser SiteUser siteUser + ) { + MentorMyPageResponse mentorMyPageResponse = mentorMyPageService.getMentorMyPage(siteUser); + return ResponseEntity.ok(mentorMyPageResponse); + } +} From 34ca47c2463a4665f8ce5dc05d7b19542043d274 Mon Sep 17 00:00:00 2001 From: nayonsoso Date: Sun, 6 Jul 2025 00:41:10 +0900 Subject: [PATCH 07/24] =?UTF-8?q?test:=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=A1=B0=ED=9A=8C=20?= =?UTF-8?q?=ED=85=8C=EC=8A=A4=ED=8A=B8=20=EC=BD=94=EB=93=9C=20=EC=9E=91?= =?UTF-8?q?=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/MentorMyPageServiceTest.java | 68 +++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 src/test/java/com/example/solidconnection/mentor/service/MentorMyPageServiceTest.java diff --git a/src/test/java/com/example/solidconnection/mentor/service/MentorMyPageServiceTest.java b/src/test/java/com/example/solidconnection/mentor/service/MentorMyPageServiceTest.java new file mode 100644 index 000000000..903681202 --- /dev/null +++ b/src/test/java/com/example/solidconnection/mentor/service/MentorMyPageServiceTest.java @@ -0,0 +1,68 @@ +package com.example.solidconnection.mentor.service; + +import com.example.solidconnection.mentor.domain.Channel; +import com.example.solidconnection.mentor.domain.Mentor; +import com.example.solidconnection.mentor.dto.ChannelResponse; +import com.example.solidconnection.mentor.dto.MentorMyPageResponse; +import com.example.solidconnection.mentor.fixture.ChannelFixture; +import com.example.solidconnection.mentor.fixture.MentorFixture; +import com.example.solidconnection.siteuser.domain.SiteUser; +import com.example.solidconnection.siteuser.fixture.SiteUserFixture; +import com.example.solidconnection.support.TestContainerSpringBootTest; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assertions.assertAll; + +@TestContainerSpringBootTest +@DisplayName("멘토 마이페이지 서비스 테스트") +class MentorMyPageServiceTest { + + @Autowired + private MentorMyPageService mentorMyPageService; + + @Autowired + private MentorFixture mentorFixture; + + @Autowired + private SiteUserFixture siteUserFixture; + + @Autowired + private ChannelFixture channelFixture; + + private SiteUser mentorUser; + private Mentor mentor; + long universityId = 1L; + + @BeforeEach + void setUp() { + mentorUser = siteUserFixture.멘토(1, "멘토"); + mentor = mentorFixture.멘토(mentorUser.getId(), universityId); + } + + @Nested + class 멘토의_마이_페이지를_조회한다 { + + @Test + void 성공적으로_조회한다() { + // given + Channel channel1 = channelFixture.채널(1, mentor); + Channel channel2 = channelFixture.채널(2, mentor); + + // when + MentorMyPageResponse response = mentorMyPageService.getMentorMyPage(mentorUser); + + // then + assertAll( + () -> assertThat(response.id()).isEqualTo(mentor.getId()), + () -> assertThat(response.nickname()).isEqualTo(mentorUser.getNickname()), + () -> assertThat(response.channels()).extracting(ChannelResponse::url) + .containsExactly(channel1.getUrl(), channel2.getUrl()) + ); + } + } +} From 92a6352c8a69d4915e114cbfe3a38b5a4815baaf Mon Sep 17 00:00:00 2001 From: nayonsoso Date: Sun, 6 Jul 2025 02:21:25 +0900 Subject: [PATCH 08/24] =?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=88=98=EC=A0=95=20?= =?UTF-8?q?=EC=9A=94=EC=B2=AD=20dto=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mentor/dto/ChannelRequest.java | 16 ++++++++++++++ .../mentor/dto/MentorMyPageUpdateRequest.java | 21 +++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 src/main/java/com/example/solidconnection/mentor/dto/ChannelRequest.java create mode 100644 src/main/java/com/example/solidconnection/mentor/dto/MentorMyPageUpdateRequest.java diff --git a/src/main/java/com/example/solidconnection/mentor/dto/ChannelRequest.java b/src/main/java/com/example/solidconnection/mentor/dto/ChannelRequest.java new file mode 100644 index 000000000..1de367184 --- /dev/null +++ b/src/main/java/com/example/solidconnection/mentor/dto/ChannelRequest.java @@ -0,0 +1,16 @@ +package com.example.solidconnection.mentor.dto; + +import com.example.solidconnection.mentor.domain.ChannelType; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; +import org.hibernate.validator.constraints.URL; + +public record ChannelRequest( + @NotNull + ChannelType type, + + @NotBlank + @URL + String url +) { +} diff --git a/src/main/java/com/example/solidconnection/mentor/dto/MentorMyPageUpdateRequest.java b/src/main/java/com/example/solidconnection/mentor/dto/MentorMyPageUpdateRequest.java new file mode 100644 index 000000000..3b64bf1bd --- /dev/null +++ b/src/main/java/com/example/solidconnection/mentor/dto/MentorMyPageUpdateRequest.java @@ -0,0 +1,21 @@ +package com.example.solidconnection.mentor.dto; + +import jakarta.validation.Valid; +import jakarta.validation.constraints.NotBlank; + +import java.util.List; + +public record MentorMyPageUpdateRequest( + @NotBlank(message = "닉네임을 입력해주세요.") + String nickname, + + @NotBlank(message = "자기소개를 입력해주세요.") + String introduction, + + @NotBlank(message = "합격 레시피를 입력해주세요.") + String passTip, + + @Valid + List channels +) { +} From a92fd09f369d350dc7b9efabe66695a97622eda8 Mon Sep 17 00:00:00 2001 From: nayonsoso Date: Sun, 6 Jul 2025 02:28:10 +0900 Subject: [PATCH 09/24] =?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=88=98=EC=A0=95=20?= =?UTF-8?q?=EC=84=9C=EB=B9=84=EC=8A=A4=20=ED=95=A8=EC=88=98=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/exception/ErrorCode.java | 2 ++ .../mentor/domain/Channel.java | 6 ++++ .../solidconnection/mentor/domain/Mentor.java | 19 +++++++++++++ .../mentor/service/MentorMyPageService.java | 28 +++++++++++++++++++ 4 files changed, 55 insertions(+) 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 3b851ef77..f2337aca6 100644 --- a/src/main/java/com/example/solidconnection/common/exception/ErrorCode.java +++ b/src/main/java/com/example/solidconnection/common/exception/ErrorCode.java @@ -101,6 +101,8 @@ public enum ErrorCode { // news INVALID_NEWS_ACCESS(HttpStatus.BAD_REQUEST.value(), "자신의 소식지만 제어할 수 있습니다."), + // mentor + CHANNEL_SEQUENCE_NOT_UNIQUE(HttpStatus.BAD_REQUEST.value(), "채널의 순서가 중복되었습니다."), // database DATA_INTEGRITY_VIOLATION(HttpStatus.CONFLICT.value(), "데이터베이스 무결성 제약조건 위반이 발생했습니다."), diff --git a/src/main/java/com/example/solidconnection/mentor/domain/Channel.java b/src/main/java/com/example/solidconnection/mentor/domain/Channel.java index 846b8e625..b3c12bff7 100644 --- a/src/main/java/com/example/solidconnection/mentor/domain/Channel.java +++ b/src/main/java/com/example/solidconnection/mentor/domain/Channel.java @@ -45,6 +45,12 @@ public class Channel { @ManyToOne(fetch = FetchType.LAZY) private Mentor mentor; + public Channel(int sequence, ChannelType type, String url) { + this.sequence = sequence; + this.type = type; + this.url = url; + } + public void updateMentor(Mentor mentor) { this.mentor = mentor; } 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 542972b9e..253bf666d 100644 --- a/src/main/java/com/example/solidconnection/mentor/domain/Mentor.java +++ b/src/main/java/com/example/solidconnection/mentor/domain/Mentor.java @@ -53,4 +53,23 @@ public class Mentor { public void increaseMenteeCount() { this.menteeCount++; } + + public void updateIntroduction(String introduction) { + this.introduction = introduction; + } + + public void updatePassTip(String passTip) { + this.passTip = passTip; + } + + public void updateChannels(List channels) { + this.channels.clear(); + if (channels == null || channels.isEmpty()) { + return; + } + for (Channel channel : channels) { + channel.updateMentor(this); + this.channels.add(channel); + } + } } 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 199415576..43d5c03d7 100644 --- a/src/main/java/com/example/solidconnection/mentor/service/MentorMyPageService.java +++ b/src/main/java/com/example/solidconnection/mentor/service/MentorMyPageService.java @@ -1,13 +1,21 @@ package com.example.solidconnection.mentor.service; 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.dto.ChannelRequest; +import com.example.solidconnection.mentor.dto.MentorMyPageUpdateRequest; import com.example.solidconnection.mentor.dto.MentorMyPageResponse; import com.example.solidconnection.mentor.repository.MentorRepository; import com.example.solidconnection.siteuser.domain.SiteUser; +import com.example.solidconnection.siteuser.service.MyPageService; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.multipart.MultipartFile; + +import java.util.ArrayList; +import java.util.List; import static com.example.solidconnection.common.exception.ErrorCode.MENTOR_NOT_FOUND; @@ -15,6 +23,9 @@ @Service public class MentorMyPageService { + private static final int CHANNEL_SEQUENCE_START_NUMBER = 1; + + private final MyPageService myPageService; private final MentorRepository mentorRepository; @Transactional(readOnly = true) @@ -23,4 +34,21 @@ public MentorMyPageResponse getMentorMyPage(SiteUser siteUser) { .orElseThrow(() -> new CustomException(MENTOR_NOT_FOUND)); return MentorMyPageResponse.of(mentor, siteUser); } + + @Transactional + public void updateMentorMyPage(SiteUser siteUser, MentorMyPageUpdateRequest mentorMyPageUpdateRequest, MultipartFile imageFile) { + Mentor mentor = mentorRepository.findBySiteUserId(siteUser.getId()) + .orElseThrow(() -> new CustomException(MENTOR_NOT_FOUND)); + + myPageService.updateMyPageInfo(siteUser, imageFile, mentorMyPageUpdateRequest.nickname()); + mentor.updateIntroduction(mentorMyPageUpdateRequest.introduction()); + mentor.updatePassTip(mentorMyPageUpdateRequest.passTip()); + + int sequence = CHANNEL_SEQUENCE_START_NUMBER; + List newChannels = new ArrayList<>(); + for (ChannelRequest request : mentorMyPageUpdateRequest.channels()) { + newChannels.add(new Channel(sequence++, request.type(), request.url())); + } + mentor.updateChannels(newChannels); + } } From ddfb3154e19a6e0d6a3fc2decea7a5a91bc7445d Mon Sep 17 00:00:00 2001 From: nayonsoso Date: Sun, 6 Jul 2025 02:29:42 +0900 Subject: [PATCH 10/24] =?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=88=98=EC=A0=95=20?= =?UTF-8?q?=EC=BB=A8=ED=8A=B8=EB=A1=A4=EB=9F=AC=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/MentorMyPageController.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) 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 5240c7259..8afb901b7 100644 --- a/src/main/java/com/example/solidconnection/mentor/controller/MentorMyPageController.java +++ b/src/main/java/com/example/solidconnection/mentor/controller/MentorMyPageController.java @@ -1,16 +1,21 @@ package com.example.solidconnection.mentor.controller; import com.example.solidconnection.common.resolver.AuthorizedUser; +import com.example.solidconnection.mentor.dto.MentorMyPageUpdateRequest; import com.example.solidconnection.mentor.dto.MentorMyPageResponse; import com.example.solidconnection.mentor.service.MentorMyPageService; import com.example.solidconnection.security.annotation.RequireRoleAccess; import com.example.solidconnection.siteuser.domain.Role; import com.example.solidconnection.siteuser.domain.SiteUser; +import jakarta.validation.Valid; import lombok.RequiredArgsConstructor; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.multipart.MultipartFile; @RequiredArgsConstructor @RequestMapping("/mentor/my") @@ -27,4 +32,15 @@ public ResponseEntity getMentorMyPage( MentorMyPageResponse mentorMyPageResponse = mentorMyPageService.getMentorMyPage(siteUser); return ResponseEntity.ok(mentorMyPageResponse); } + + @RequireRoleAccess(roles = {Role.MENTOR}) + @PutMapping + public ResponseEntity updateMentorMyPage( + @AuthorizedUser SiteUser siteUser, + @Valid MentorMyPageUpdateRequest mentorMyPageUpdateRequest, + @RequestParam(value = "file", required = false) MultipartFile imageFile + ) { + mentorMyPageService.updateMentorMyPage(siteUser, mentorMyPageUpdateRequest, imageFile); + return ResponseEntity.ok().build(); + } } From 31d5c1da640a63d90e7405b9ae27108a32a1c646 Mon Sep 17 00:00:00 2001 From: nayonsoso Date: Sun, 6 Jul 2025 02:30:28 +0900 Subject: [PATCH 11/24] =?UTF-8?q?test:=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=88=98=EC=A0=95=20?= =?UTF-8?q?=ED=85=8C=EC=8A=A4=ED=8A=B8=20=EC=BD=94=EB=93=9C=20=EC=9E=91?= =?UTF-8?q?=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../repository/ChannelRepositoryForTest.java | 11 +++ .../service/MentorMyPageServiceTest.java | 91 ++++++++++++++++++- 2 files changed, 101 insertions(+), 1 deletion(-) create mode 100644 src/test/java/com/example/solidconnection/mentor/repository/ChannelRepositoryForTest.java diff --git a/src/test/java/com/example/solidconnection/mentor/repository/ChannelRepositoryForTest.java b/src/test/java/com/example/solidconnection/mentor/repository/ChannelRepositoryForTest.java new file mode 100644 index 000000000..9e6fee1de --- /dev/null +++ b/src/test/java/com/example/solidconnection/mentor/repository/ChannelRepositoryForTest.java @@ -0,0 +1,11 @@ +package com.example.solidconnection.mentor.repository; + +import com.example.solidconnection.mentor.domain.Channel; +import org.springframework.data.jpa.repository.JpaRepository; + +import java.util.List; + +public interface ChannelRepositoryForTest extends JpaRepository { + + List findAllByMentorId(long mentorId); +} 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 903681202..125e977cd 100644 --- a/src/test/java/com/example/solidconnection/mentor/service/MentorMyPageServiceTest.java +++ b/src/test/java/com/example/solidconnection/mentor/service/MentorMyPageServiceTest.java @@ -2,21 +2,34 @@ import com.example.solidconnection.mentor.domain.Channel; import com.example.solidconnection.mentor.domain.Mentor; +import com.example.solidconnection.mentor.dto.ChannelRequest; import com.example.solidconnection.mentor.dto.ChannelResponse; 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.MentorFixture; +import com.example.solidconnection.mentor.repository.ChannelRepositoryForTest; +import com.example.solidconnection.mentor.repository.MentorRepository; import com.example.solidconnection.siteuser.domain.SiteUser; import com.example.solidconnection.siteuser.fixture.SiteUserFixture; +import com.example.solidconnection.siteuser.service.MyPageService; import com.example.solidconnection.support.TestContainerSpringBootTest; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.mock.web.MockMultipartFile; +import java.util.List; + +import static com.example.solidconnection.mentor.domain.ChannelType.BLOG; +import static com.example.solidconnection.mentor.domain.ChannelType.INSTAGRAM; import static org.assertj.core.api.Assertions.assertThat; import static org.junit.jupiter.api.Assertions.assertAll; +import static org.mockito.BDDMockito.then; +import static org.mockito.Mockito.times; @TestContainerSpringBootTest @DisplayName("멘토 마이페이지 서비스 테스트") @@ -34,9 +47,18 @@ class MentorMyPageServiceTest { @Autowired private ChannelFixture channelFixture; + @Autowired + private MentorRepository mentorRepository; + + @Autowired + private ChannelRepositoryForTest channelRepositoryForTest; + + @MockBean + private MyPageService myPageService; + private SiteUser mentorUser; private Mentor mentor; - long universityId = 1L; + private long universityId = 1L; @BeforeEach void setUp() { @@ -65,4 +87,71 @@ class 멘토의_마이_페이지를_조회한다 { ); } } + + @Nested + class 멘토의_마이_페이지를_수정한다 { + + @Test + void 멘토의_사용자_정보_수정은_기존_수정로직에_위임한다() { + // given + String newNickname = "새로운 닉네임"; + MockMultipartFile newProfileImg = createImageFile(); + MentorMyPageUpdateRequest request = new MentorMyPageUpdateRequest(newNickname, "자기소개", "합격 팁", List.of()); + + // when + mentorMyPageService.updateMentorMyPage(mentorUser, request, newProfileImg); + + // then + then(myPageService).should(times(1)) + .updateMyPageInfo(mentorUser, newProfileImg, newNickname); + } + + @Test + void 멘토_정보를_수정한다() { + // given + String newIntroduction = "새로운 자기소개"; + String newPassTip = "새로운 합격 팁"; + MentorMyPageUpdateRequest request = new MentorMyPageUpdateRequest("nickname", newIntroduction, newPassTip, List.of()); + + // when + mentorMyPageService.updateMentorMyPage(mentorUser, request, null); + + // then + Mentor updatedMentor = mentorRepository.findById(mentor.getId()).get(); + assertAll( + () -> assertThat(updatedMentor.getIntroduction()).isEqualTo(newIntroduction), + () -> assertThat(updatedMentor.getPassTip()).isEqualTo(newPassTip) + ); + } + + @Test + void 채널_정보를_수정한다() { + // given + List newChannels = List.of( + new ChannelRequest(BLOG, "https://blog.com"), + new ChannelRequest(INSTAGRAM, "https://instagram.com") + ); + MentorMyPageUpdateRequest request = new MentorMyPageUpdateRequest("nickname", "introduction", "passTip", newChannels); + + // when + mentorMyPageService.updateMentorMyPage(mentorUser, request, null); + // then + List updatedChannels = channelRepositoryForTest.findAllByMentorId(mentor.getId()); + assertAll( + () -> assertThat(updatedChannels).extracting(Channel::getType) + .containsExactly(BLOG, INSTAGRAM), + () -> assertThat(updatedChannels).extracting(Channel::getUrl) + .containsExactly("https://blog.com", "https://instagram.com") + ); + } + } + + private MockMultipartFile createImageFile() { + return new MockMultipartFile( + "image", + "test.jpg", + "image/jpeg", + "test image content".getBytes() + ); + } } From 7917b404c4c877ec4463748707c2294a27f26f22 Mon Sep 17 00:00:00 2001 From: nayonsoso Date: Mon, 7 Jul 2025 23:31:41 +0900 Subject: [PATCH 12/24] =?UTF-8?q?style:=20=EB=B6=88=ED=95=84=EC=9A=94?= =?UTF-8?q?=ED=95=9C=20=EC=A4=91=EA=B4=84=ED=98=B8=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mentor/controller/MentorMyPageController.java | 4 ++-- 1 file changed, 2 insertions(+), 2 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 8afb901b7..8460d19fa 100644 --- a/src/main/java/com/example/solidconnection/mentor/controller/MentorMyPageController.java +++ b/src/main/java/com/example/solidconnection/mentor/controller/MentorMyPageController.java @@ -1,8 +1,8 @@ package com.example.solidconnection.mentor.controller; import com.example.solidconnection.common.resolver.AuthorizedUser; -import com.example.solidconnection.mentor.dto.MentorMyPageUpdateRequest; import com.example.solidconnection.mentor.dto.MentorMyPageResponse; +import com.example.solidconnection.mentor.dto.MentorMyPageUpdateRequest; import com.example.solidconnection.mentor.service.MentorMyPageService; import com.example.solidconnection.security.annotation.RequireRoleAccess; import com.example.solidconnection.siteuser.domain.Role; @@ -33,7 +33,7 @@ public ResponseEntity getMentorMyPage( return ResponseEntity.ok(mentorMyPageResponse); } - @RequireRoleAccess(roles = {Role.MENTOR}) + @RequireRoleAccess(roles = Role.MENTOR) @PutMapping public ResponseEntity updateMentorMyPage( @AuthorizedUser SiteUser siteUser, From 97af40417732819ec4ba6386c5c28bb00e153f5d Mon Sep 17 00:00:00 2001 From: nayonsoso Date: Mon, 7 Jul 2025 23:35:45 +0900 Subject: [PATCH 13/24] =?UTF-8?q?chore:=20=EC=82=AC=EC=9A=A9=EB=90=98?= =?UTF-8?q?=EC=A7=80=20=EC=95=8A=EB=8A=94=20=EB=B3=80=EC=88=98=20=EC=A0=9C?= =?UTF-8?q?=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mentor/repository/MentorBatchQueryRepositoryTest.java | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/test/java/com/example/solidconnection/mentor/repository/MentorBatchQueryRepositoryTest.java b/src/test/java/com/example/solidconnection/mentor/repository/MentorBatchQueryRepositoryTest.java index 0ef517c34..4b991fd58 100644 --- a/src/test/java/com/example/solidconnection/mentor/repository/MentorBatchQueryRepositoryTest.java +++ b/src/test/java/com/example/solidconnection/mentor/repository/MentorBatchQueryRepositoryTest.java @@ -1,9 +1,7 @@ package com.example.solidconnection.mentor.repository; import com.example.solidconnection.mentor.domain.Mentor; -import com.example.solidconnection.mentor.domain.Mentoring; import com.example.solidconnection.mentor.fixture.MentorFixture; -import com.example.solidconnection.mentor.fixture.MentoringFixture; import com.example.solidconnection.siteuser.domain.SiteUser; import com.example.solidconnection.siteuser.fixture.SiteUserFixture; import com.example.solidconnection.support.TestContainerSpringBootTest; @@ -31,9 +29,6 @@ class MentorBatchQueryRepositoryTest { @Autowired private SiteUserFixture siteUserFixture; - @Autowired - private MentoringFixture mentoringFixture; - private long universityId = 1L; // todo: 멘토 인증 기능 추가 변경 필요 private Mentor mentor1, mentor2; private SiteUser mentorUser1, mentorUser2, currentUser; @@ -65,7 +60,6 @@ void setUp() { @Test void 멘토_ID_와_현재_사용자의_지원_여부를_매핑한다() { // given - Mentoring 대기중_멘토링 = mentoringFixture.대기중_멘토링(mentor1.getId(), currentUser.getId()); List mentors = List.of(mentor1, mentor2); // when From be32db89eb4785a0fcf26c8fa77fdbe30a5b3859 Mon Sep 17 00:00:00 2001 From: nayonsoso Date: Mon, 7 Jul 2025 23:42:41 +0900 Subject: [PATCH 14/24] =?UTF-8?q?refactor:=20=EB=B3=80=EC=88=98=EB=AA=85?= =?UTF-8?q?=20=EB=8B=A8=EC=88=9C=ED=99=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mentor/service/MentorMyPageService.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) 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 43d5c03d7..f717c4f1a 100644 --- a/src/main/java/com/example/solidconnection/mentor/service/MentorMyPageService.java +++ b/src/main/java/com/example/solidconnection/mentor/service/MentorMyPageService.java @@ -4,8 +4,8 @@ import com.example.solidconnection.mentor.domain.Channel; import com.example.solidconnection.mentor.domain.Mentor; import com.example.solidconnection.mentor.dto.ChannelRequest; -import com.example.solidconnection.mentor.dto.MentorMyPageUpdateRequest; import com.example.solidconnection.mentor.dto.MentorMyPageResponse; +import com.example.solidconnection.mentor.dto.MentorMyPageUpdateRequest; import com.example.solidconnection.mentor.repository.MentorRepository; import com.example.solidconnection.siteuser.domain.SiteUser; import com.example.solidconnection.siteuser.service.MyPageService; @@ -36,18 +36,18 @@ public MentorMyPageResponse getMentorMyPage(SiteUser siteUser) { } @Transactional - public void updateMentorMyPage(SiteUser siteUser, MentorMyPageUpdateRequest mentorMyPageUpdateRequest, MultipartFile imageFile) { + public void updateMentorMyPage(SiteUser siteUser, MentorMyPageUpdateRequest request, MultipartFile imageFile) { Mentor mentor = mentorRepository.findBySiteUserId(siteUser.getId()) .orElseThrow(() -> new CustomException(MENTOR_NOT_FOUND)); - myPageService.updateMyPageInfo(siteUser, imageFile, mentorMyPageUpdateRequest.nickname()); - mentor.updateIntroduction(mentorMyPageUpdateRequest.introduction()); - mentor.updatePassTip(mentorMyPageUpdateRequest.passTip()); + myPageService.updateMyPageInfo(siteUser, imageFile, request.nickname()); + mentor.updateIntroduction(request.introduction()); + mentor.updatePassTip(request.passTip()); int sequence = CHANNEL_SEQUENCE_START_NUMBER; List newChannels = new ArrayList<>(); - for (ChannelRequest request : mentorMyPageUpdateRequest.channels()) { - newChannels.add(new Channel(sequence++, request.type(), request.url())); + for (ChannelRequest channelRequest : request.channels()) { + newChannels.add(new Channel(sequence++, channelRequest.type(), channelRequest.url())); } mentor.updateChannels(newChannels); } From c19906a8c5a646a76e23a7aac06ffe34b620c8eb Mon Sep 17 00:00:00 2001 From: nayonsoso Date: Mon, 7 Jul 2025 23:46:16 +0900 Subject: [PATCH 15/24] =?UTF-8?q?refactor:=20=EC=B5=9C=EB=8C=80=20?= =?UTF-8?q?=EC=B1=84=EB=84=90=20=EB=93=B1=EB=A1=9D=20=EA=B0=AF=EC=88=98=20?= =?UTF-8?q?=EA=B2=80=EC=A6=9D=20=EC=B6=94=EA=B0=80,=20=ED=95=A8=EC=88=98?= =?UTF-8?q?=20=EB=B6=84=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/exception/ErrorCode.java | 1 + .../mentor/service/MentorMyPageService.java | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) 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 f2337aca6..0ea4b29a5 100644 --- a/src/main/java/com/example/solidconnection/common/exception/ErrorCode.java +++ b/src/main/java/com/example/solidconnection/common/exception/ErrorCode.java @@ -103,6 +103,7 @@ public enum ErrorCode { // mentor CHANNEL_SEQUENCE_NOT_UNIQUE(HttpStatus.BAD_REQUEST.value(), "채널의 순서가 중복되었습니다."), + CHANNEL_REGISTRATION_LIMIT_EXCEEDED(HttpStatus.BAD_REQUEST.value(), "등록 가능한 채널 수를 초과하였습니다."), // database DATA_INTEGRITY_VIOLATION(HttpStatus.CONFLICT.value(), "데이터베이스 무결성 제약조건 위반이 발생했습니다."), 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 f717c4f1a..5ca577380 100644 --- a/src/main/java/com/example/solidconnection/mentor/service/MentorMyPageService.java +++ b/src/main/java/com/example/solidconnection/mentor/service/MentorMyPageService.java @@ -17,12 +17,14 @@ import java.util.ArrayList; import java.util.List; +import static com.example.solidconnection.common.exception.ErrorCode.CHANNEL_REGISTRATION_LIMIT_EXCEEDED; import static com.example.solidconnection.common.exception.ErrorCode.MENTOR_NOT_FOUND; @RequiredArgsConstructor @Service public class MentorMyPageService { + private static final int CHANNEL_REGISTRATION_LIMIT = 4; private static final int CHANNEL_SEQUENCE_START_NUMBER = 1; private final MyPageService myPageService; @@ -37,17 +39,27 @@ public MentorMyPageResponse getMentorMyPage(SiteUser siteUser) { @Transactional public void updateMentorMyPage(SiteUser siteUser, MentorMyPageUpdateRequest request, MultipartFile imageFile) { + validateChannelRegistrationLimit(request.channels()); Mentor mentor = mentorRepository.findBySiteUserId(siteUser.getId()) .orElseThrow(() -> new CustomException(MENTOR_NOT_FOUND)); myPageService.updateMyPageInfo(siteUser, imageFile, request.nickname()); mentor.updateIntroduction(request.introduction()); mentor.updatePassTip(request.passTip()); + updateChannel(request.channels(), mentor); + } + + 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) { int sequence = CHANNEL_SEQUENCE_START_NUMBER; List newChannels = new ArrayList<>(); - for (ChannelRequest channelRequest : request.channels()) { - newChannels.add(new Channel(sequence++, channelRequest.type(), channelRequest.url())); + for (ChannelRequest request : channelRequests) { + newChannels.add(new Channel(sequence++, request.type(), request.url())); } mentor.updateChannels(newChannels); } From 7fcca239bc6426bd2c0a2c89dcb1d98019417218 Mon Sep 17 00:00:00 2001 From: nayonsoso Date: Mon, 7 Jul 2025 23:47:01 +0900 Subject: [PATCH 16/24] =?UTF-8?q?style:=20=EA=B0=9C=ED=96=89=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../solidconnection/mentor/service/MentorMyPageServiceTest.java | 1 + 1 file changed, 1 insertion(+) 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 125e977cd..18062c733 100644 --- a/src/test/java/com/example/solidconnection/mentor/service/MentorMyPageServiceTest.java +++ b/src/test/java/com/example/solidconnection/mentor/service/MentorMyPageServiceTest.java @@ -135,6 +135,7 @@ class 멘토의_마이_페이지를_수정한다 { // when mentorMyPageService.updateMentorMyPage(mentorUser, request, null); + // then List updatedChannels = channelRepositoryForTest.findAllByMentorId(mentor.getId()); assertAll( From 0dcceda5050f216d48913c45ecf6fe59a1fe29df Mon Sep 17 00:00:00 2001 From: nayonsoso Date: Mon, 7 Jul 2025 23:50:12 +0900 Subject: [PATCH 17/24] =?UTF-8?q?refactor:=20=EB=A9=98=ED=86=A0=20?= =?UTF-8?q?=EB=A7=88=EC=9D=B4=20=ED=8E=98=EC=9D=B4=EC=A7=80=EC=97=90?= =?UTF-8?q?=EC=84=9C=20=EC=82=AC=EC=9A=A9=EC=9E=90=20=EC=A0=95=EB=B3=B4?= =?UTF-8?q?=EB=A5=BC=20=EC=88=98=EC=A0=95=ED=95=98=EC=A7=80=20=EC=95=8A?= =?UTF-8?q?=EB=8F=84=EB=A1=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/MentorMyPageController.java | 7 +--- .../mentor/dto/MentorMyPageUpdateRequest.java | 3 -- .../mentor/service/MentorMyPageService.java | 4 +- .../service/MentorMyPageServiceTest.java | 40 ++----------------- 4 files changed, 7 insertions(+), 47 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 8460d19fa..170fcd013 100644 --- a/src/main/java/com/example/solidconnection/mentor/controller/MentorMyPageController.java +++ b/src/main/java/com/example/solidconnection/mentor/controller/MentorMyPageController.java @@ -13,9 +13,7 @@ import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; -import org.springframework.web.multipart.MultipartFile; @RequiredArgsConstructor @RequestMapping("/mentor/my") @@ -37,10 +35,9 @@ public ResponseEntity getMentorMyPage( @PutMapping public ResponseEntity updateMentorMyPage( @AuthorizedUser SiteUser siteUser, - @Valid MentorMyPageUpdateRequest mentorMyPageUpdateRequest, - @RequestParam(value = "file", required = false) MultipartFile imageFile + @Valid MentorMyPageUpdateRequest mentorMyPageUpdateRequest ) { - mentorMyPageService.updateMentorMyPage(siteUser, mentorMyPageUpdateRequest, imageFile); + mentorMyPageService.updateMentorMyPage(siteUser, mentorMyPageUpdateRequest); return ResponseEntity.ok().build(); } } diff --git a/src/main/java/com/example/solidconnection/mentor/dto/MentorMyPageUpdateRequest.java b/src/main/java/com/example/solidconnection/mentor/dto/MentorMyPageUpdateRequest.java index 3b64bf1bd..5a6790aeb 100644 --- a/src/main/java/com/example/solidconnection/mentor/dto/MentorMyPageUpdateRequest.java +++ b/src/main/java/com/example/solidconnection/mentor/dto/MentorMyPageUpdateRequest.java @@ -6,9 +6,6 @@ import java.util.List; public record MentorMyPageUpdateRequest( - @NotBlank(message = "닉네임을 입력해주세요.") - String nickname, - @NotBlank(message = "자기소개를 입력해주세요.") String introduction, 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 5ca577380..98fd52545 100644 --- a/src/main/java/com/example/solidconnection/mentor/service/MentorMyPageService.java +++ b/src/main/java/com/example/solidconnection/mentor/service/MentorMyPageService.java @@ -12,7 +12,6 @@ import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import org.springframework.web.multipart.MultipartFile; import java.util.ArrayList; import java.util.List; @@ -38,12 +37,11 @@ public MentorMyPageResponse getMentorMyPage(SiteUser siteUser) { } @Transactional - public void updateMentorMyPage(SiteUser siteUser, MentorMyPageUpdateRequest request, MultipartFile imageFile) { + public void updateMentorMyPage(SiteUser siteUser, MentorMyPageUpdateRequest request) { validateChannelRegistrationLimit(request.channels()); Mentor mentor = mentorRepository.findBySiteUserId(siteUser.getId()) .orElseThrow(() -> new CustomException(MENTOR_NOT_FOUND)); - myPageService.updateMyPageInfo(siteUser, imageFile, request.nickname()); mentor.updateIntroduction(request.introduction()); mentor.updatePassTip(request.passTip()); updateChannel(request.channels(), mentor); 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 18062c733..b7c5724a7 100644 --- a/src/test/java/com/example/solidconnection/mentor/service/MentorMyPageServiceTest.java +++ b/src/test/java/com/example/solidconnection/mentor/service/MentorMyPageServiceTest.java @@ -12,15 +12,12 @@ import com.example.solidconnection.mentor.repository.MentorRepository; import com.example.solidconnection.siteuser.domain.SiteUser; import com.example.solidconnection.siteuser.fixture.SiteUserFixture; -import com.example.solidconnection.siteuser.service.MyPageService; import com.example.solidconnection.support.TestContainerSpringBootTest; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.mock.web.MockMultipartFile; import java.util.List; @@ -28,8 +25,6 @@ import static com.example.solidconnection.mentor.domain.ChannelType.INSTAGRAM; import static org.assertj.core.api.Assertions.assertThat; import static org.junit.jupiter.api.Assertions.assertAll; -import static org.mockito.BDDMockito.then; -import static org.mockito.Mockito.times; @TestContainerSpringBootTest @DisplayName("멘토 마이페이지 서비스 테스트") @@ -53,9 +48,6 @@ class MentorMyPageServiceTest { @Autowired private ChannelRepositoryForTest channelRepositoryForTest; - @MockBean - private MyPageService myPageService; - private SiteUser mentorUser; private Mentor mentor; private long universityId = 1L; @@ -91,30 +83,15 @@ class 멘토의_마이_페이지를_조회한다 { @Nested class 멘토의_마이_페이지를_수정한다 { - @Test - void 멘토의_사용자_정보_수정은_기존_수정로직에_위임한다() { - // given - String newNickname = "새로운 닉네임"; - MockMultipartFile newProfileImg = createImageFile(); - MentorMyPageUpdateRequest request = new MentorMyPageUpdateRequest(newNickname, "자기소개", "합격 팁", List.of()); - - // when - mentorMyPageService.updateMentorMyPage(mentorUser, request, newProfileImg); - - // then - then(myPageService).should(times(1)) - .updateMyPageInfo(mentorUser, newProfileImg, newNickname); - } - @Test void 멘토_정보를_수정한다() { // given String newIntroduction = "새로운 자기소개"; String newPassTip = "새로운 합격 팁"; - MentorMyPageUpdateRequest request = new MentorMyPageUpdateRequest("nickname", newIntroduction, newPassTip, List.of()); + MentorMyPageUpdateRequest request = new MentorMyPageUpdateRequest(newIntroduction, newPassTip, List.of()); // when - mentorMyPageService.updateMentorMyPage(mentorUser, request, null); + mentorMyPageService.updateMentorMyPage(mentorUser, request); // then Mentor updatedMentor = mentorRepository.findById(mentor.getId()).get(); @@ -131,10 +108,10 @@ class 멘토의_마이_페이지를_수정한다 { new ChannelRequest(BLOG, "https://blog.com"), new ChannelRequest(INSTAGRAM, "https://instagram.com") ); - MentorMyPageUpdateRequest request = new MentorMyPageUpdateRequest("nickname", "introduction", "passTip", newChannels); + MentorMyPageUpdateRequest request = new MentorMyPageUpdateRequest("introduction", "passTip", newChannels); // when - mentorMyPageService.updateMentorMyPage(mentorUser, request, null); + mentorMyPageService.updateMentorMyPage(mentorUser, request); // then List updatedChannels = channelRepositoryForTest.findAllByMentorId(mentor.getId()); @@ -146,13 +123,4 @@ class 멘토의_마이_페이지를_수정한다 { ); } } - - private MockMultipartFile createImageFile() { - return new MockMultipartFile( - "image", - "test.jpg", - "image/jpeg", - "test image content".getBytes() - ); - } } From f84b6ababc4fca1e7211bffd6ecc9827dc2f37fb Mon Sep 17 00:00:00 2001 From: nayonsoso Date: Mon, 7 Jul 2025 23:50:33 +0900 Subject: [PATCH 18/24] =?UTF-8?q?refactor:=20=EB=88=84=EB=9D=BD=ED=95=9C?= =?UTF-8?q?=20=EA=B2=80=EC=A6=9D=20=EB=A9=94=EC=84=B8=EC=A7=80=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../example/solidconnection/mentor/dto/ChannelRequest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/example/solidconnection/mentor/dto/ChannelRequest.java b/src/main/java/com/example/solidconnection/mentor/dto/ChannelRequest.java index 1de367184..9172262ae 100644 --- a/src/main/java/com/example/solidconnection/mentor/dto/ChannelRequest.java +++ b/src/main/java/com/example/solidconnection/mentor/dto/ChannelRequest.java @@ -6,10 +6,10 @@ import org.hibernate.validator.constraints.URL; public record ChannelRequest( - @NotNull + @NotNull(message = "채널 종류를 입력해주세요.") ChannelType type, - @NotBlank + @NotBlank(message = "채널 URL을 입력해주세요.") @URL String url ) { From a54bf507934dd5db7c7e4fa3cf177c83423736a6 Mon Sep 17 00:00:00 2001 From: nayonsoso Date: Tue, 8 Jul 2025 21:16:44 +0900 Subject: [PATCH 19/24] =?UTF-8?q?style:=20=EB=B6=88=ED=95=84=EC=9A=94?= =?UTF-8?q?=ED=95=9C=20=EC=A4=91=EA=B4=84=ED=98=B8=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mentor/controller/MentorMyPageController.java | 2 +- 1 file changed, 1 insertion(+), 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 170fcd013..b50dd364b 100644 --- a/src/main/java/com/example/solidconnection/mentor/controller/MentorMyPageController.java +++ b/src/main/java/com/example/solidconnection/mentor/controller/MentorMyPageController.java @@ -22,7 +22,7 @@ public class MentorMyPageController { private final MentorMyPageService mentorMyPageService; - @RequireRoleAccess(roles = {Role.MENTOR}) + @RequireRoleAccess(roles = Role.MENTOR) @GetMapping public ResponseEntity getMentorMyPage( @AuthorizedUser SiteUser siteUser From 787d63664103cd523933833bc104b26559358b28 Mon Sep 17 00:00:00 2001 From: nayonsoso Date: Tue, 8 Jul 2025 21:18:03 +0900 Subject: [PATCH 20/24] =?UTF-8?q?refactor:=20=EB=88=84=EB=9D=BD=ED=95=9C?= =?UTF-8?q?=20RequestBody=20=EC=96=B4=EB=85=B8=ED=85=8C=EC=9D=B4=EC=85=98?= =?UTF-8?q?=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mentor/controller/MentorMyPageController.java | 3 ++- 1 file changed, 2 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 b50dd364b..9a39cdb30 100644 --- a/src/main/java/com/example/solidconnection/mentor/controller/MentorMyPageController.java +++ b/src/main/java/com/example/solidconnection/mentor/controller/MentorMyPageController.java @@ -12,6 +12,7 @@ import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @@ -35,7 +36,7 @@ public ResponseEntity getMentorMyPage( @PutMapping public ResponseEntity updateMentorMyPage( @AuthorizedUser SiteUser siteUser, - @Valid MentorMyPageUpdateRequest mentorMyPageUpdateRequest + @Valid @RequestBody MentorMyPageUpdateRequest mentorMyPageUpdateRequest ) { mentorMyPageService.updateMentorMyPage(siteUser, mentorMyPageUpdateRequest); return ResponseEntity.ok().build(); From 83dfae48c5e72c930956013ece119068bf3dad94 Mon Sep 17 00:00:00 2001 From: nayonsoso Date: Tue, 8 Jul 2025 21:19:08 +0900 Subject: [PATCH 21/24] =?UTF-8?q?refactor:=20=EB=B6=88=ED=95=84=EC=9A=94?= =?UTF-8?q?=ED=95=9C=20=EB=B9=88=20=EC=A3=BC=EC=9E=85=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../solidconnection/mentor/service/MentorMyPageService.java | 2 -- 1 file changed, 2 deletions(-) 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 98fd52545..6a2d47ded 100644 --- a/src/main/java/com/example/solidconnection/mentor/service/MentorMyPageService.java +++ b/src/main/java/com/example/solidconnection/mentor/service/MentorMyPageService.java @@ -8,7 +8,6 @@ import com.example.solidconnection.mentor.dto.MentorMyPageUpdateRequest; import com.example.solidconnection.mentor.repository.MentorRepository; import com.example.solidconnection.siteuser.domain.SiteUser; -import com.example.solidconnection.siteuser.service.MyPageService; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -26,7 +25,6 @@ public class MentorMyPageService { private static final int CHANNEL_REGISTRATION_LIMIT = 4; private static final int CHANNEL_SEQUENCE_START_NUMBER = 1; - private final MyPageService myPageService; private final MentorRepository mentorRepository; @Transactional(readOnly = true) From 0551bff5efefeb5b99be7df5e758f08aa83f3ba1 Mon Sep 17 00:00:00 2001 From: nayonsoso Date: Thu, 10 Jul 2025 01:31:47 +0900 Subject: [PATCH 22/24] =?UTF-8?q?style:=20=EC=82=AC=EC=9A=A9=EB=90=98?= =?UTF-8?q?=EC=A7=80=20=EC=95=8A=EB=8A=94=20import=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../solidconnection/mentor/controller/MentorController.java | 3 --- .../solidconnection/mentor/service/MentorQueryService.java | 5 ----- 2 files changed, 8 deletions(-) diff --git a/src/main/java/com/example/solidconnection/mentor/controller/MentorController.java b/src/main/java/com/example/solidconnection/mentor/controller/MentorController.java index 9c04c6a47..ea60b180c 100644 --- a/src/main/java/com/example/solidconnection/mentor/controller/MentorController.java +++ b/src/main/java/com/example/solidconnection/mentor/controller/MentorController.java @@ -3,14 +3,11 @@ import com.example.solidconnection.common.dto.SliceResponse; import com.example.solidconnection.common.resolver.AuthorizedUser; import com.example.solidconnection.mentor.dto.MentorDetailResponse; -import com.example.solidconnection.mentor.dto.MentorPreviewsResponse; import com.example.solidconnection.mentor.dto.MentorPreviewResponse; import com.example.solidconnection.mentor.service.MentorQueryService; import com.example.solidconnection.siteuser.domain.SiteUser; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Pageable; -import org.springframework.data.web.PageableDefault; -import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Sort; import org.springframework.data.web.PageableDefault; import org.springframework.data.web.SortDefault; 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 e3d95fb0f..a7c46e285 100644 --- a/src/main/java/com/example/solidconnection/mentor/service/MentorQueryService.java +++ b/src/main/java/com/example/solidconnection/mentor/service/MentorQueryService.java @@ -6,9 +6,6 @@ import com.example.solidconnection.mentor.dto.MentorDetailResponse; import com.example.solidconnection.mentor.dto.MentorPreviewResponse; import com.example.solidconnection.mentor.repository.MentorBatchQueryRepository; -import com.example.solidconnection.mentor.dto.MentorPreviewResponse; -import com.example.solidconnection.mentor.dto.MentorPreviewsResponse; -import com.example.solidconnection.mentor.repository.MentorBatchQueryRepository; import com.example.solidconnection.mentor.repository.MentorRepository; import com.example.solidconnection.mentor.repository.MentoringRepository; import com.example.solidconnection.siteuser.domain.SiteUser; @@ -16,8 +13,6 @@ import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Slice; -import org.springframework.data.domain.Page; -import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; From 9c37b7655ef29a2f8dfa4708aa54caf6a4b9c24b Mon Sep 17 00:00:00 2001 From: nayonsoso Date: Thu, 10 Jul 2025 01:32:06 +0900 Subject: [PATCH 23/24] =?UTF-8?q?refactor:=20=EC=9E=98=EB=AA=BB=EB=90=9C?= =?UTF-8?q?=20=EB=B0=98=ED=99=98=20=ED=83=80=EC=9E=85=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mentor/controller/MentorMyPageController.java | 2 +- 1 file changed, 1 insertion(+), 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 9a39cdb30..ba8bc0911 100644 --- a/src/main/java/com/example/solidconnection/mentor/controller/MentorMyPageController.java +++ b/src/main/java/com/example/solidconnection/mentor/controller/MentorMyPageController.java @@ -34,7 +34,7 @@ public ResponseEntity getMentorMyPage( @RequireRoleAccess(roles = Role.MENTOR) @PutMapping - public ResponseEntity updateMentorMyPage( + public ResponseEntity updateMentorMyPage( @AuthorizedUser SiteUser siteUser, @Valid @RequestBody MentorMyPageUpdateRequest mentorMyPageUpdateRequest ) { From a440c57576ed53c4edf297d0785fa6a6f9b130d3 Mon Sep 17 00:00:00 2001 From: nayonsoso Date: Thu, 10 Jul 2025 01:43:44 +0900 Subject: [PATCH 24/24] =?UTF-8?q?fix:=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20?= =?UTF-8?q?=EA=B9=A8=EC=A7=80=EB=8A=94=20=EA=B3=B3=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mentor/repository/MentorBatchQueryRepositoryTest.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/test/java/com/example/solidconnection/mentor/repository/MentorBatchQueryRepositoryTest.java b/src/test/java/com/example/solidconnection/mentor/repository/MentorBatchQueryRepositoryTest.java index 4b991fd58..c68deedb7 100644 --- a/src/test/java/com/example/solidconnection/mentor/repository/MentorBatchQueryRepositoryTest.java +++ b/src/test/java/com/example/solidconnection/mentor/repository/MentorBatchQueryRepositoryTest.java @@ -2,6 +2,7 @@ import com.example.solidconnection.mentor.domain.Mentor; import com.example.solidconnection.mentor.fixture.MentorFixture; +import com.example.solidconnection.mentor.fixture.MentoringFixture; import com.example.solidconnection.siteuser.domain.SiteUser; import com.example.solidconnection.siteuser.fixture.SiteUserFixture; import com.example.solidconnection.support.TestContainerSpringBootTest; @@ -26,6 +27,9 @@ class MentorBatchQueryRepositoryTest { @Autowired private MentorFixture mentorFixture; + @Autowired + private MentoringFixture mentoringFixture; + @Autowired private SiteUserFixture siteUserFixture; @@ -60,6 +64,7 @@ void setUp() { @Test void 멘토_ID_와_현재_사용자의_지원_여부를_매핑한다() { // given + mentoringFixture.대기중_멘토링(mentor1.getId(), currentUser.getId()); List mentors = List.of(mentor1, mentor2); // when