diff --git a/backend/baton/src/main/java/touch/baton/config/WebMvcConfig.java b/backend/baton/src/main/java/touch/baton/config/WebMvcConfig.java new file mode 100644 index 000000000..fb1ecc9ee --- /dev/null +++ b/backend/baton/src/main/java/touch/baton/config/WebMvcConfig.java @@ -0,0 +1,25 @@ +package touch.baton.config; + +import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.config.annotation.CorsRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; +import static org.springframework.http.HttpHeaders.LOCATION; +import static org.springframework.http.HttpMethod.DELETE; +import static org.springframework.http.HttpMethod.GET; +import static org.springframework.http.HttpMethod.OPTIONS; +import static org.springframework.http.HttpMethod.PATCH; +import static org.springframework.http.HttpMethod.POST; +import static org.springframework.http.HttpMethod.PUT; + +@Configuration +public class WebMvcConfig implements WebMvcConfigurer { + @Override + public void addCorsMappings(final CorsRegistry registry) { + registry.addMapping("/**") + .allowedOrigins("http://localhost:3000") + .allowCredentials(false) + .allowedMethods(GET.name(), POST.name(), PUT.name(), PATCH.name(), DELETE.name(), OPTIONS.name()) + .exposedHeaders(LOCATION) + .maxAge(3600); + } +} diff --git a/backend/baton/src/main/java/touch/baton/domain/runnerpost/controller/response/ProfileResponse.java b/backend/baton/src/main/java/touch/baton/domain/runnerpost/controller/response/ProfileResponse.java deleted file mode 100644 index 0c12b6935..000000000 --- a/backend/baton/src/main/java/touch/baton/domain/runnerpost/controller/response/ProfileResponse.java +++ /dev/null @@ -1,32 +0,0 @@ -package touch.baton.domain.runnerpost.controller.response; - -import touch.baton.domain.member.Member; - -public record ProfileResponse() { - - public record Detail(Long memberId, - String name, - String company, - String imageUrl - ) { - - public static Detail from(final Member member) { - return new Detail( - member.getId(), - member.getMemberName().getValue(), - member.getCompany().getValue(), - member.getImageUrl().getValue() - ); - } - } - - public record Simple(String name, String imageUrl) { - - public static Simple from(final Member member) { - return new Simple( - member.getMemberName().getValue(), - member.getImageUrl().getValue() - ); - } - } -} diff --git a/backend/baton/src/main/java/touch/baton/domain/runnerpost/controller/response/RunnerPostResponse.java b/backend/baton/src/main/java/touch/baton/domain/runnerpost/controller/response/RunnerPostResponse.java index cd38d48ad..fe9af9a67 100644 --- a/backend/baton/src/main/java/touch/baton/domain/runnerpost/controller/response/RunnerPostResponse.java +++ b/backend/baton/src/main/java/touch/baton/domain/runnerpost/controller/response/RunnerPostResponse.java @@ -2,6 +2,7 @@ import com.fasterxml.jackson.annotation.JsonFormat; import touch.baton.domain.runnerpost.RunnerPost; +import touch.baton.domain.runnerpost.vo.ReviewStatus; import java.time.LocalDateTime; import java.util.List; @@ -10,27 +11,31 @@ public record RunnerPostResponse() { public record Detail(Long runnerPostId, String title, + String contents, + String pullRequestUrl, @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm", timezone = "Asia/Seoul") LocalDateTime deadline, - List tags, - String contents, - Integer chattingCount, Integer watchedCount, + Integer chattingCount, + ReviewStatus reviewStatus, boolean isOwner, - ProfileResponse.Detail profile + RunnerProfileResponse.Detail runnerProfile, + List tags ) { public static Detail from(final RunnerPost runnerPost) { return new Detail( runnerPost.getId(), runnerPost.getTitle().getValue(), - runnerPost.getDeadline().getValue(), - convertToTags(runnerPost), runnerPost.getContents().getValue(), - runnerPost.getChattingCount().getValue(), + runnerPost.getPullRequestUrl().getValue(), + runnerPost.getDeadline().getValue(), runnerPost.getWatchedCount().getValue(), + runnerPost.getChattingCount().getValue(), + runnerPost.getReviewStatus(), true, - ProfileResponse.Detail.from(runnerPost.getRunner().getMember()) + RunnerProfileResponse.Detail.from(runnerPost.getRunner()), + convertToTags(runnerPost) ); } } @@ -38,28 +43,32 @@ public static Detail from(final RunnerPost runnerPost) { public record DetailVersionTest(Long runnerPostId, String title, + String contents, + String pullRequestUrl, @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm", timezone = "Asia/Seoul") LocalDateTime deadline, - List tags, - String contents, - boolean isOwner, - Integer chattingCount, Integer watchedCount, - ProfileResponse.Detail profile, - SupporterResponseTestVersion.Simple supporter + Integer chattingCount, + ReviewStatus reviewStatus, + RunnerProfileResponse.Detail runnerProfile, + SupporterResponseTestVersion.Simple supporterProfile, + boolean isOwner, + List tags ) { public static DetailVersionTest fromVersionTest(final RunnerPost runnerPost) { return new DetailVersionTest( runnerPost.getId(), runnerPost.getTitle().getValue(), - runnerPost.getDeadline().getValue(), - convertToTags(runnerPost), runnerPost.getContents().getValue(), - true, - runnerPost.getChattingCount().getValue(), + runnerPost.getPullRequestUrl().getValue(), + runnerPost.getDeadline().getValue(), runnerPost.getWatchedCount().getValue(), - ProfileResponse.Detail.from(runnerPost.getRunner().getMember()), - SupporterResponseTestVersion.Simple.fromTestVersion(runnerPost.getSupporter()) + runnerPost.getChattingCount().getValue(), + runnerPost.getReviewStatus(), + RunnerProfileResponse.Detail.from(runnerPost.getRunner()), + SupporterResponseTestVersion.Simple.fromTestVersion(runnerPost.getSupporter()), + true, + convertToTags(runnerPost) ); } } @@ -68,11 +77,11 @@ public record Simple(Long runnerPostId, String title, @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm", timezone = "Asia/Seoul") LocalDateTime deadline, - List tags, - ProfileResponse.Simple profile, int watchedCount, int chattingCount, - String reviewStatus + String reviewStatus, + RunnerProfileResponse.Simple runnerProfile, + List tags ) { public static Simple from(final RunnerPost runnerPost) { @@ -80,11 +89,11 @@ public static Simple from(final RunnerPost runnerPost) { runnerPost.getId(), runnerPost.getTitle().getValue(), runnerPost.getDeadline().getValue(), - convertToTags(runnerPost), - ProfileResponse.Simple.from(runnerPost.getRunner().getMember()), runnerPost.getWatchedCount().getValue(), runnerPost.getChattingCount().getValue(), - runnerPost.getReviewStatus().name() + runnerPost.getReviewStatus().name(), + RunnerProfileResponse.Simple.from(runnerPost.getRunner()), + convertToTags(runnerPost) ); } } diff --git a/backend/baton/src/main/java/touch/baton/domain/runnerpost/controller/response/RunnerProfileResponse.java b/backend/baton/src/main/java/touch/baton/domain/runnerpost/controller/response/RunnerProfileResponse.java new file mode 100644 index 000000000..e41dff18d --- /dev/null +++ b/backend/baton/src/main/java/touch/baton/domain/runnerpost/controller/response/RunnerProfileResponse.java @@ -0,0 +1,32 @@ +package touch.baton.domain.runnerpost.controller.response; + +import touch.baton.domain.runner.Runner; + +public record RunnerProfileResponse() { + + public record Detail(Long runnerId, + String name, + String company, + String imageUrl + ) { + + public static Detail from(final Runner runner) { + return new Detail( + runner.getId(), + runner.getMember().getMemberName().getValue(), + runner.getMember().getCompany().getValue(), + runner.getMember().getImageUrl().getValue() + ); + } + } + + public record Simple(String name, String imageUrl) { + + public static Simple from(final Runner runner) { + return new Simple( + runner.getMember().getMemberName().getValue(), + runner.getMember().getImageUrl().getValue() + ); + } + } +} diff --git a/backend/baton/src/test/java/touch/baton/assure/runnerpost/RunnerPostAssuredSupport.java b/backend/baton/src/test/java/touch/baton/assure/runnerpost/RunnerPostAssuredSupport.java index 3341aa705..44fc5ab1d 100644 --- a/backend/baton/src/test/java/touch/baton/assure/runnerpost/RunnerPostAssuredSupport.java +++ b/backend/baton/src/test/java/touch/baton/assure/runnerpost/RunnerPostAssuredSupport.java @@ -53,10 +53,10 @@ public RunnerPostServerResponseBuilder(final ExtractableResponse respo () -> assertThat(actual.contents()).isEqualTo(러너_게시글_응답.contents()), () -> assertThat(actual.tags()).isEqualTo(러너_게시글_응답.tags()), () -> assertThat(actual.deadline()).isEqualToIgnoringSeconds(러너_게시글_응답.deadline()), - () -> assertThat(actual.profile().name()).isEqualTo(러너_게시글_응답.profile().name()), - () -> assertThat(actual.profile().company()).isEqualTo(러너_게시글_응답.profile().company()), - () -> assertThat(actual.profile().imageUrl()).isEqualTo(러너_게시글_응답.profile().imageUrl()), - () -> assertThat(actual.profile().memberId()).isEqualTo(러너_게시글_응답.profile().memberId()), + () -> assertThat(actual.runnerProfile().name()).isEqualTo(러너_게시글_응답.runnerProfile().name()), + () -> assertThat(actual.runnerProfile().company()).isEqualTo(러너_게시글_응답.runnerProfile().company()), + () -> assertThat(actual.runnerProfile().imageUrl()).isEqualTo(러너_게시글_응답.runnerProfile().imageUrl()), + () -> assertThat(actual.runnerProfile().runnerId()).isEqualTo(러너_게시글_응답.runnerProfile().runnerId()), () -> assertThat(actual.chattingCount()).isEqualTo(러너_게시글_응답.chattingCount()), () -> assertThat(actual.watchedCount()).isEqualTo(러너_게시글_응답.watchedCount()), () -> assertThat(actual.runnerPostId()).isEqualTo(러너_게시글_응답.runnerPostId()) diff --git a/backend/baton/src/test/java/touch/baton/domain/runnerpost/RunnerPostTest.java b/backend/baton/src/test/java/touch/baton/domain/runnerpost/RunnerPostTest.java index 8378ea8df..69d7afb41 100644 --- a/backend/baton/src/test/java/touch/baton/domain/runnerpost/RunnerPostTest.java +++ b/backend/baton/src/test/java/touch/baton/domain/runnerpost/RunnerPostTest.java @@ -93,7 +93,7 @@ void success() { ).doesNotThrowAnyException(); } - @DisplayName("supporter 에 null 이 들어간 경우 아직 리뷰어 할당이 되지 않은 것이다.") + @DisplayName("supporterProfile 에 null 이 들어간 경우 아직 리뷰어 할당이 되지 않은 것이다.") @Test void success_if_supporter_is_null() { assertThatCode(() -> RunnerPost.builder()