Skip to content

Commit

Permalink
"/profile/runner" api 삭제 (#619)
Browse files Browse the repository at this point in the history
* test: 전체 조회 인수 테스트

* test: 지원자 수 조회 repo 테스트

* refactor: page model attribute 적용

* refactor: 서포터 관련 게시글 페이지네이션

* refactor: querydsl repository 추상화 해제

* test: 서포터 id 로 러너 게시글 조회 레포지토리 테스트

* feat: runner id 로 러너 게시글 조회 repository 구현

* refactor: response dto query 패키지로 이동

* refactor: PageResponse 로 응답 변경

* refactor: 필요없는 메소드 삭제

* refactor: runnerpost 테스트 패키징 변경

* test: runner로 runnerPost 조회 api 테스트

* docs: 명세서 오류 수정

* refactor: pageResponse 생성자 인자 변경

* refactor: pathParams 에서 limit + 1 되도록 수정

* refactor: querydsl config 테스트용 생성

* refactor: 테스트 자원 정리

* feat: PageInfo에 다음 커서 추가

* refactor: PageParams 패키지 위치 변경

* refactor: api 삭제

* refactor: supporter read response 삭제

* refactor: runner response 두 개 합치기

* refactor: 충돌 해결
  • Loading branch information
shb03323 authored Oct 7, 2023
1 parent d57ea4c commit d2c0171
Show file tree
Hide file tree
Showing 14 changed files with 53 additions and 188 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<RunnerMyProfileResponse> readMyProfile(@AuthRunnerPrincipal final Runner runner) {
final RunnerResponse.Mine me = RunnerResponse.Mine.from(runner);
final List<RunnerPostResponse.Mine> runnerPosts = runnerPostQueryService.readRunnerPostsByRunnerId(runner.getId()).stream()
.map(RunnerPostResponse.Mine::from)
.toList();
return ResponseEntity.ok(new RunnerMyProfileResponse(me, runnerPosts));
}

@GetMapping("/me")
public ResponseEntity<RunnerResponse.MyProfile> readMyProfileByToken(@AuthRunnerPrincipal Runner runner) {
final RunnerResponse.MyProfile response = RunnerResponse.MyProfile.from(runner);

public ResponseEntity<RunnerResponse.Mine> readMyProfileByToken(@AuthRunnerPrincipal Runner runner) {
final RunnerResponse.Mine response = RunnerResponse.Mine.from(runner);
return ResponseEntity.ok(response);
}

@GetMapping("/{runnerId}")
public ResponseEntity<RunnerProfileResponse.Detail> readRunnerProfile(@PathVariable Long runnerId) {
public ResponseEntity<RunnerResponse.Detail> 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);
}
}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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<String> technicalTags
) {

public static Detail from(final Runner runner) {
return new Detail(
final List<String> 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(),
Expand All @@ -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<String> 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<String> technicalTags
) {

public static MyProfile from(final Runner runner) {
return new MyProfile(
runner.getMember().getMemberName().getValue(),
runner.getMember().getCompany().getValue(),
runner.getMember().getImageUrl().getValue(),
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public record Detail(Long runnerPostId,
boolean isOwner,
boolean isApplied,
List<String> tags,
RunnerResponse.Detail runnerProfile
RunnerResponse.InRunnerPostDetail runnerProfile
) {

public static Detail of(final RunnerPost runnerPost,
Expand All @@ -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())
);
}
}
Expand Down Expand Up @@ -84,24 +84,6 @@ public Long extractId() {
}
}

public record Mine(Long runnerPostId,
String title,
LocalDateTime deadline,
List<String> 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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -21,7 +22,7 @@ class RunnerQueryAssuredTest extends AssuredTestConfig {
final Runner 러너_헤나 = runnerRepository.getBySocialId(헤나_소셜_아이디);

// when, then
RunnerUpdateAssuredSupport
RunnerQueryAssuredSupport
.클라이언트_요청()
.액세스_토큰으로_로그인한다(헤나_액세스_토큰)
.러너_본인_프로필을_가지고_있는_액세스_토큰으로_조회한다()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -28,8 +25,8 @@ private RunnerUpdateAssuredSupport() {
return new RunnerUpdateBuilder();
}

public static RunnerResponse.MyProfile 러너_본인_프로필_응답(final Runner 러너, final List<String> 러너_태그_목록) {
return new RunnerResponse.MyProfile(
public static RunnerResponse.Mine 러너_본인_프로필_응답(final Runner 러너, final List<String> 러너_태그_목록) {
return new RunnerResponse.Mine(
러너.getMember().getMemberName().getValue(),
러너.getMember().getCompany().getValue(),
러너.getMember().getImageUrl().getValue(),
Expand Down Expand Up @@ -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;
Expand All @@ -90,34 +77,6 @@ public RunnerUpdateResponseBuilder(final ExtractableResponse<Response> 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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -24,17 +22,6 @@ private RunnerQueryAssuredSupport() {
return new RunnerQueryBuilder();
}

public static RunnerResponse.MyProfile 러너_본인_프로필_응답(final Runner 러너, final List<String> 러너_태그_목록) {
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> response;
Expand Down Expand Up @@ -73,8 +60,8 @@ public RunnerQueryResponseBuilder(final ExtractableResponse<Response> 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(),
Expand All @@ -85,8 +72,8 @@ public RunnerQueryResponseBuilder(final ExtractableResponse<Response> 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());
Expand All @@ -98,8 +85,8 @@ public RunnerQueryResponseBuilder(final ExtractableResponse<Response> 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();
Expand Down
Loading

0 comments on commit d2c0171

Please sign in to comment.