diff --git a/backend/baton/src/main/java/touch/baton/domain/member/query/controller/RunnerQueryController.java b/backend/baton/src/main/java/touch/baton/domain/member/query/controller/RunnerQueryController.java index 05c69f51f..073670b57 100644 --- a/backend/baton/src/main/java/touch/baton/domain/member/query/controller/RunnerQueryController.java +++ b/backend/baton/src/main/java/touch/baton/domain/member/query/controller/RunnerQueryController.java @@ -7,44 +7,27 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import touch.baton.domain.member.command.Runner; -import touch.baton.domain.member.query.controller.response.RunnerMyProfileResponse; -import touch.baton.domain.member.query.controller.response.RunnerProfileResponse; import touch.baton.domain.member.query.controller.response.RunnerResponse; import touch.baton.domain.member.query.service.RunnerQueryService; import touch.baton.domain.oauth.query.controller.resolver.AuthRunnerPrincipal; -import touch.baton.domain.runnerpost.query.controller.response.RunnerPostResponse; -import touch.baton.domain.runnerpost.query.service.RunnerPostQueryService; - -import java.util.List; @RequiredArgsConstructor @RequestMapping("/api/v1/profile/runner") @RestController public class RunnerQueryController { - private final RunnerPostQueryService runnerPostQueryService; private final RunnerQueryService runnerQueryService; - // FIXME: 2023/09/26 runnerPostQueryService로 옮기기 - @GetMapping - public ResponseEntity readMyProfile(@AuthRunnerPrincipal final Runner runner) { - final RunnerResponse.Mine me = RunnerResponse.Mine.from(runner); - final List runnerPosts = runnerPostQueryService.readRunnerPostsByRunnerId(runner.getId()).stream() - .map(RunnerPostResponse.Mine::from) - .toList(); - return ResponseEntity.ok(new RunnerMyProfileResponse(me, runnerPosts)); - } - @GetMapping("/me") - public ResponseEntity readMyProfileByToken(@AuthRunnerPrincipal Runner runner) { - final RunnerResponse.MyProfile response = RunnerResponse.MyProfile.from(runner); - + public ResponseEntity readMyProfileByToken(@AuthRunnerPrincipal Runner runner) { + final RunnerResponse.Mine response = RunnerResponse.Mine.from(runner); return ResponseEntity.ok(response); } @GetMapping("/{runnerId}") - public ResponseEntity readRunnerProfile(@PathVariable Long runnerId) { + public ResponseEntity readRunnerProfile(@PathVariable Long runnerId) { final Runner runner = runnerQueryService.readByRunnerId(runnerId); - return ResponseEntity.ok(RunnerProfileResponse.Detail.from(runner)); + final RunnerResponse.Detail response = RunnerResponse.Detail.from(runner); + return ResponseEntity.ok(response); } } diff --git a/backend/baton/src/main/java/touch/baton/domain/member/query/controller/response/RunnerMyProfileResponse.java b/backend/baton/src/main/java/touch/baton/domain/member/query/controller/response/RunnerMyProfileResponse.java deleted file mode 100644 index 7f6275ba3..000000000 --- a/backend/baton/src/main/java/touch/baton/domain/member/query/controller/response/RunnerMyProfileResponse.java +++ /dev/null @@ -1,10 +0,0 @@ -package touch.baton.domain.member.query.controller.response; - -import touch.baton.domain.runnerpost.query.controller.response.RunnerPostResponse; - -import java.util.List; - -public record RunnerMyProfileResponse(RunnerResponse.Mine profile, - List runnerPosts -) { -} diff --git a/backend/baton/src/main/java/touch/baton/domain/member/query/controller/response/RunnerProfileResponse.java b/backend/baton/src/main/java/touch/baton/domain/member/query/controller/response/RunnerProfileResponse.java deleted file mode 100644 index c543d574c..000000000 --- a/backend/baton/src/main/java/touch/baton/domain/member/query/controller/response/RunnerProfileResponse.java +++ /dev/null @@ -1,34 +0,0 @@ -package touch.baton.domain.member.query.controller.response; - -import touch.baton.domain.member.command.Member; -import touch.baton.domain.member.command.Runner; - -import java.util.List; - -public record RunnerProfileResponse() { - - public record Detail(Long runnerId, - String name, - String imageUrl, - String githubUrl, - String introduction, - String company, - List technicalTags - ) { - - public static Detail from(final Runner runner) { - final List tagNames = runner.getRunnerTechnicalTags().getRunnerTechnicalTags().stream() - .map(runnerTechnicalTag -> runnerTechnicalTag.getTechnicalTag().getTagName().getValue()) - .toList(); - - final Member member = runner.getMember(); - return new Detail(runner.getId(), - member.getMemberName().getValue(), - member.getImageUrl().getValue(), - member.getGithubUrl().getValue(), - runner.getIntroduction().getValue(), - member.getCompany().getValue(), - tagNames); - } - } -} diff --git a/backend/baton/src/main/java/touch/baton/domain/member/query/controller/response/RunnerResponse.java b/backend/baton/src/main/java/touch/baton/domain/member/query/controller/response/RunnerResponse.java index a03118816..2728cfda8 100644 --- a/backend/baton/src/main/java/touch/baton/domain/member/query/controller/response/RunnerResponse.java +++ b/backend/baton/src/main/java/touch/baton/domain/member/query/controller/response/RunnerResponse.java @@ -1,5 +1,6 @@ package touch.baton.domain.member.query.controller.response; +import touch.baton.domain.member.command.Member; import touch.baton.domain.member.command.Runner; import java.util.List; @@ -8,12 +9,37 @@ public record RunnerResponse() { public record Detail(Long runnerId, String name, + String imageUrl, + String githubUrl, + String introduction, String company, - String imageUrl + List technicalTags ) { public static Detail from(final Runner runner) { - return new Detail( + final List tagNames = runner.getRunnerTechnicalTags().getRunnerTechnicalTags().stream() + .map(runnerTechnicalTag -> runnerTechnicalTag.getTechnicalTag().getTagName().getValue()) + .toList(); + + final Member member = runner.getMember(); + return new Detail(runner.getId(), + member.getMemberName().getValue(), + member.getImageUrl().getValue(), + member.getGithubUrl().getValue(), + runner.getIntroduction().getValue(), + member.getCompany().getValue(), + tagNames); + } + } + + public record InRunnerPostDetail(Long runnerId, + String name, + String company, + String imageUrl + ) { + + public static InRunnerPostDetail from(final Runner runner) { + return new InRunnerPostDetail( runner.getId(), runner.getMember().getMemberName().getValue(), runner.getMember().getCompany().getValue(), @@ -33,31 +59,15 @@ public static Simple from(final Runner runner) { } public record Mine(String name, + String company, String imageUrl, String githubUrl, - String introduction + String introduction, + List technicalTags ) { public static Mine from(final Runner runner) { return new Mine( - runner.getMember().getMemberName().getValue(), - runner.getMember().getImageUrl().getValue(), - runner.getMember().getGithubUrl().getValue(), - runner.getIntroduction().getValue() - ); - } - } - - public record MyProfile(String name, - String company, - String imageUrl, - String githubUrl, - String introduction, - List technicalTags - ) { - - public static MyProfile from(final Runner runner) { - return new MyProfile( runner.getMember().getMemberName().getValue(), runner.getMember().getCompany().getValue(), runner.getMember().getImageUrl().getValue(), diff --git a/backend/baton/src/main/java/touch/baton/domain/member/query/controller/response/SupporterReadResponses.java b/backend/baton/src/main/java/touch/baton/domain/member/query/controller/response/SupporterReadResponses.java deleted file mode 100644 index 3e7153287..000000000 --- a/backend/baton/src/main/java/touch/baton/domain/member/query/controller/response/SupporterReadResponses.java +++ /dev/null @@ -1,13 +0,0 @@ -package touch.baton.domain.member.query.controller.response; - -import java.util.List; - -public record SupporterReadResponses() { - - public record NoFiltering(List data) { - - public static NoFiltering from(final List data) { - return new SupporterReadResponses.NoFiltering(data); - } - } -} diff --git a/backend/baton/src/main/java/touch/baton/domain/runnerpost/query/controller/response/RunnerPostResponse.java b/backend/baton/src/main/java/touch/baton/domain/runnerpost/query/controller/response/RunnerPostResponse.java index 136547fc6..f3dfadbbf 100644 --- a/backend/baton/src/main/java/touch/baton/domain/runnerpost/query/controller/response/RunnerPostResponse.java +++ b/backend/baton/src/main/java/touch/baton/domain/runnerpost/query/controller/response/RunnerPostResponse.java @@ -25,7 +25,7 @@ public record Detail(Long runnerPostId, boolean isOwner, boolean isApplied, List tags, - RunnerResponse.Detail runnerProfile + RunnerResponse.InRunnerPostDetail runnerProfile ) { public static Detail of(final RunnerPost runnerPost, @@ -47,7 +47,7 @@ public static Detail of(final RunnerPost runnerPost, isOwner, isApplied, convertToTags(runnerPost), - RunnerResponse.Detail.from(runnerPost.getRunner()) + RunnerResponse.InRunnerPostDetail.from(runnerPost.getRunner()) ); } } @@ -84,24 +84,6 @@ public Long extractId() { } } - public record Mine(Long runnerPostId, - String title, - LocalDateTime deadline, - List tags, - String reviewStatus - ) { - - public static Mine from(final RunnerPost runnerPost) { - return new Mine( - runnerPost.getId(), - runnerPost.getTitle().getValue(), - runnerPost.getDeadline().getValue(), - convertToTags(runnerPost), - runnerPost.getReviewStatus().name() - ); - } - } - public record SimpleByRunner(Long runnerPostId, String title, LocalDateTime deadline, diff --git a/backend/baton/src/test/java/touch/baton/assure/member/query/RunnerQueryAssuredTest.java b/backend/baton/src/test/java/touch/baton/assure/member/query/RunnerQueryAssuredTest.java index 132470131..ffd76b000 100644 --- a/backend/baton/src/test/java/touch/baton/assure/member/query/RunnerQueryAssuredTest.java +++ b/backend/baton/src/test/java/touch/baton/assure/member/query/RunnerQueryAssuredTest.java @@ -2,6 +2,7 @@ import org.junit.jupiter.api.Test; import touch.baton.assure.member.support.command.RunnerUpdateAssuredSupport; +import touch.baton.assure.member.support.query.RunnerQueryAssuredSupport; import touch.baton.config.AssuredTestConfig; import touch.baton.config.infra.auth.oauth.authcode.MockAuthCodes; import touch.baton.domain.member.command.Runner; @@ -21,7 +22,7 @@ class RunnerQueryAssuredTest extends AssuredTestConfig { final Runner 러너_헤나 = runnerRepository.getBySocialId(헤나_소셜_아이디); // when, then - RunnerUpdateAssuredSupport + RunnerQueryAssuredSupport .클라이언트_요청() .액세스_토큰으로_로그인한다(헤나_액세스_토큰) .러너_본인_프로필을_가지고_있는_액세스_토큰으로_조회한다() diff --git a/backend/baton/src/test/java/touch/baton/assure/member/support/command/RunnerUpdateAssuredSupport.java b/backend/baton/src/test/java/touch/baton/assure/member/support/command/RunnerUpdateAssuredSupport.java index 07339b0e9..25c24a3cd 100644 --- a/backend/baton/src/test/java/touch/baton/assure/member/support/command/RunnerUpdateAssuredSupport.java +++ b/backend/baton/src/test/java/touch/baton/assure/member/support/command/RunnerUpdateAssuredSupport.java @@ -5,16 +5,13 @@ import org.springframework.http.HttpHeaders; import touch.baton.assure.common.AssuredSupport; import touch.baton.assure.common.HttpStatusAndLocationHeader; -import touch.baton.assure.common.PathParams; import touch.baton.domain.common.exception.ClientErrorCode; import touch.baton.domain.common.response.ErrorResponse; import touch.baton.domain.member.command.Runner; import touch.baton.domain.member.command.service.dto.RunnerUpdateRequest; -import touch.baton.domain.member.query.controller.response.RunnerProfileResponse; import touch.baton.domain.member.query.controller.response.RunnerResponse; import java.util.List; -import java.util.Map; import static org.assertj.core.api.SoftAssertions.assertSoftly; @@ -28,8 +25,8 @@ private RunnerUpdateAssuredSupport() { return new RunnerUpdateBuilder(); } - public static RunnerResponse.MyProfile 러너_본인_프로필_응답(final Runner 러너, final List 러너_태그_목록) { - return new RunnerResponse.MyProfile( + public static RunnerResponse.Mine 러너_본인_프로필_응답(final Runner 러너, final List 러너_태그_목록) { + return new RunnerResponse.Mine( 러너.getMember().getMemberName().getValue(), 러너.getMember().getCompany().getValue(), 러너.getMember().getImageUrl().getValue(), @@ -58,16 +55,6 @@ public static class RunnerUpdateBuilder { return this; } - public RunnerUpdateBuilder 러너_본인_프로필을_가지고_있는_액세스_토큰으로_조회한다() { - response = AssuredSupport.get("/api/v1/profile/runner/me", accessToken); - return this; - } - - public RunnerUpdateBuilder 러너_프로필을_상세_조회한다(final Long 러너_식별자) { - response = AssuredSupport.get("/api/v1/profile/runner/{runnerId}", new PathParams(Map.of("runnerId", 러너_식별자))); - return this; - } - public RunnerUpdateBuilder 러너_본인_프로필을_수정한다(final RunnerUpdateRequest 러너_업데이트_요청) { response = AssuredSupport.patch("/api/v1/profile/runner/me", accessToken, 러너_업데이트_요청); return this; @@ -90,34 +77,6 @@ public RunnerUpdateResponseBuilder(final ExtractableResponse response) return new RunnerUpdateBuilder(); } - public void 러너_본인_프로필_조회_성공을_검증한다(final RunnerResponse.MyProfile 러너_본인_프로필_응답) { - final RunnerResponse.MyProfile actual = this.response.as(RunnerResponse.MyProfile.class); - - assertSoftly(softly -> { - softly.assertThat(actual.name()).isEqualTo(러너_본인_프로필_응답.name()); - softly.assertThat(actual.company()).isEqualTo(러너_본인_프로필_응답.company()); - softly.assertThat(actual.imageUrl()).isEqualTo(러너_본인_프로필_응답.imageUrl()); - softly.assertThat(actual.githubUrl()).isEqualTo(러너_본인_프로필_응답.githubUrl()); - softly.assertThat(actual.introduction()).isEqualTo(러너_본인_프로필_응답.introduction()); - softly.assertThat(actual.technicalTags()).isEqualTo(러너_본인_프로필_응답.technicalTags()); - }); - } - - public void 러너_프로필_상세_조회를_검증한다(final RunnerProfileResponse.Detail 러너_프로필_상세_응답) { - final RunnerProfileResponse.Detail actual = this.response.as(RunnerProfileResponse.Detail.class); - - assertSoftly(softly -> { - softly.assertThat(actual.runnerId()).isNotNull(); - softly.assertThat(actual.name()).isEqualTo(러너_프로필_상세_응답.name()); - softly.assertThat(actual.imageUrl()).isEqualTo(러너_프로필_상세_응답.imageUrl()); - softly.assertThat(actual.githubUrl()).isEqualTo(러너_프로필_상세_응답.githubUrl()); - softly.assertThat(actual.introduction()).isEqualTo(러너_프로필_상세_응답.introduction()); - softly.assertThat(actual.company()).isEqualTo(러너_프로필_상세_응답.company()); - softly.assertThat(actual.technicalTags()).containsExactlyElementsOf(러너_프로필_상세_응답.technicalTags()); - } - ); - } - public void 러너_본인_프로필_수정_성공을_검증한다(final HttpStatusAndLocationHeader 응답상태_및_로케이션) { assertSoftly(softly -> { softly.assertThat(response.statusCode()).isEqualTo(응답상태_및_로케이션.getHttpStatus().value()); diff --git a/backend/baton/src/test/java/touch/baton/assure/member/support/query/RunnerQueryAssuredSupport.java b/backend/baton/src/test/java/touch/baton/assure/member/support/query/RunnerQueryAssuredSupport.java index 6d12a1393..ec9fecf84 100644 --- a/backend/baton/src/test/java/touch/baton/assure/member/support/query/RunnerQueryAssuredSupport.java +++ b/backend/baton/src/test/java/touch/baton/assure/member/support/query/RunnerQueryAssuredSupport.java @@ -6,10 +6,8 @@ import touch.baton.assure.common.PathParams; import touch.baton.domain.member.command.Runner; import touch.baton.domain.member.command.service.dto.RunnerUpdateRequest; -import touch.baton.domain.member.query.controller.response.RunnerProfileResponse; import touch.baton.domain.member.query.controller.response.RunnerResponse; -import java.util.List; import java.util.Map; import static org.assertj.core.api.SoftAssertions.assertSoftly; @@ -24,17 +22,6 @@ private RunnerQueryAssuredSupport() { return new RunnerQueryBuilder(); } - public static RunnerResponse.MyProfile 러너_본인_프로필_응답(final Runner 러너, final List 러너_태그_목록) { - return new RunnerResponse.MyProfile( - 러너.getMember().getMemberName().getValue(), - 러너.getMember().getCompany().getValue(), - 러너.getMember().getImageUrl().getValue(), - 러너.getMember().getGithubUrl().getValue(), - 러너.getIntroduction().getValue(), - 러너_태그_목록 - ); - } - public static class RunnerQueryBuilder { private ExtractableResponse response; @@ -73,8 +60,8 @@ public RunnerQueryResponseBuilder(final ExtractableResponse response) return new RunnerQueryBuilder(); } - public static RunnerProfileResponse.Detail 러너_프로필_상세_응답(final Runner 러너, final RunnerUpdateRequest 러너_본인_프로필_수정_요청) { - return new RunnerProfileResponse.Detail( + public static RunnerResponse.Detail 러너_프로필_상세_응답(final Runner 러너, final RunnerUpdateRequest 러너_본인_프로필_수정_요청) { + return new RunnerResponse.Detail( 러너.getId(), 러너_본인_프로필_수정_요청.name(), 러너.getMember().getImageUrl().getValue(), @@ -85,8 +72,8 @@ public RunnerQueryResponseBuilder(final ExtractableResponse response) ); } - public void 러너_본인_프로필_조회_성공을_검증한다(final RunnerResponse.MyProfile 러너_본인_프로필_응답) { - final RunnerResponse.MyProfile actual = this.response.as(RunnerResponse.MyProfile.class); + public void 러너_본인_프로필_조회_성공을_검증한다(final RunnerResponse.Mine 러너_본인_프로필_응답) { + final RunnerResponse.Mine actual = this.response.as(RunnerResponse.Mine.class); assertSoftly(softly -> { softly.assertThat(actual.name()).isEqualTo(러너_본인_프로필_응답.name()); @@ -98,8 +85,8 @@ public RunnerQueryResponseBuilder(final ExtractableResponse response) }); } - public void 러너_프로필_상세_조회를_검증한다(final RunnerProfileResponse.Detail 러너_프로필_상세_응답) { - final RunnerProfileResponse.Detail actual = this.response.as(RunnerProfileResponse.Detail.class); + public void 러너_프로필_상세_조회를_검증한다(final RunnerResponse.Detail 러너_프로필_상세_응답) { + final RunnerResponse.Detail actual = this.response.as(RunnerResponse.Detail.class); assertSoftly(softly -> { softly.assertThat(actual.runnerId()).isNotNull(); diff --git a/backend/baton/src/test/java/touch/baton/assure/runnerpost/query/detail/RunnerPostDetailAssuredTest.java b/backend/baton/src/test/java/touch/baton/assure/runnerpost/query/detail/RunnerPostInRunnerPostDetailAssuredTest.java similarity index 98% rename from backend/baton/src/test/java/touch/baton/assure/runnerpost/query/detail/RunnerPostDetailAssuredTest.java rename to backend/baton/src/test/java/touch/baton/assure/runnerpost/query/detail/RunnerPostInRunnerPostDetailAssuredTest.java index fbbaf4995..b0ef23bef 100644 --- a/backend/baton/src/test/java/touch/baton/assure/runnerpost/query/detail/RunnerPostDetailAssuredTest.java +++ b/backend/baton/src/test/java/touch/baton/assure/runnerpost/query/detail/RunnerPostInRunnerPostDetailAssuredTest.java @@ -18,7 +18,7 @@ import static touch.baton.fixture.vo.WatchedCountFixture.watchedCount; @SuppressWarnings("NonAsciiCharacters") -class RunnerPostDetailAssuredTest extends AssuredTestConfig { +class RunnerPostInRunnerPostDetailAssuredTest extends AssuredTestConfig { @Test void 러너의_게시글_식별자값으로_러너_게시글_상세_정보_조회에_성공한다() { diff --git a/backend/baton/src/test/java/touch/baton/assure/runnerpost/support/query/detail/RunnerPostDetailSupport.java b/backend/baton/src/test/java/touch/baton/assure/runnerpost/support/query/detail/RunnerPostDetailSupport.java index 572ad552b..a82a1c0ee 100644 --- a/backend/baton/src/test/java/touch/baton/assure/runnerpost/support/query/detail/RunnerPostDetailSupport.java +++ b/backend/baton/src/test/java/touch/baton/assure/runnerpost/support/query/detail/RunnerPostDetailSupport.java @@ -54,7 +54,7 @@ private RunnerPostDetailSupport() { 주인_여부, 서포터_지원_여부, 태그_목록, - RunnerResponse.Detail.from(러너) + RunnerResponse.InRunnerPostDetail.from(러너) ); } diff --git a/backend/baton/src/test/java/touch/baton/document/profile/runner/read/RunnerReadByGuestApiTest.java b/backend/baton/src/test/java/touch/baton/document/profile/runner/read/RunnerReadByGuestApiTest.java index 7b4585ecc..1a882ff9c 100644 --- a/backend/baton/src/test/java/touch/baton/document/profile/runner/read/RunnerReadByGuestApiTest.java +++ b/backend/baton/src/test/java/touch/baton/document/profile/runner/read/RunnerReadByGuestApiTest.java @@ -49,7 +49,7 @@ class RunnerReadByGuestApiTest extends RestdocsConfig { @BeforeEach void setUp() { - restdocsSetUp(new RunnerQueryController(runnerPostQueryService, runnerQueryService)); + restdocsSetUp(new RunnerQueryController(runnerQueryService)); } @DisplayName("러너 본인 프로필 조회 API") diff --git a/backend/baton/src/test/java/touch/baton/document/profile/runner/read/RunnerReadSimpleByRunnerIdApiTest.java b/backend/baton/src/test/java/touch/baton/document/profile/runner/read/RunnerReadSimpleByRunnerIdApiTest.java index 834a113a9..fb7505a30 100644 --- a/backend/baton/src/test/java/touch/baton/document/profile/runner/read/RunnerReadSimpleByRunnerIdApiTest.java +++ b/backend/baton/src/test/java/touch/baton/document/profile/runner/read/RunnerReadSimpleByRunnerIdApiTest.java @@ -44,7 +44,7 @@ public class RunnerReadSimpleByRunnerIdApiTest extends RestdocsConfig { @BeforeEach void setUp() { - final RunnerQueryController runnerQueryController = new RunnerQueryController(runnerPostQueryService, runnerQueryService); + final RunnerQueryController runnerQueryController = new RunnerQueryController(runnerQueryService); restdocsSetUp(runnerQueryController); } diff --git a/backend/baton/src/test/java/touch/baton/document/profile/runner/read/RunnerReadWithLoginedRunnerApiTest.java b/backend/baton/src/test/java/touch/baton/document/profile/runner/read/RunnerReadWithLoginedRunnerApiTest.java index 906bd572f..86faa77e6 100644 --- a/backend/baton/src/test/java/touch/baton/document/profile/runner/read/RunnerReadWithLoginedRunnerApiTest.java +++ b/backend/baton/src/test/java/touch/baton/document/profile/runner/read/RunnerReadWithLoginedRunnerApiTest.java @@ -42,7 +42,7 @@ class RunnerReadWithLoginedRunnerApiTest extends RestdocsConfig { @BeforeEach void setUp() { - final RunnerQueryController runnerQueryController = new RunnerQueryController(runnerPostQueryService, runnerQueryService); + final RunnerQueryController runnerQueryController = new RunnerQueryController(runnerQueryService); restdocsSetUp(runnerQueryController); }