From 8fecf290760b30b8196db8c2dcfe2734024929a8 Mon Sep 17 00:00:00 2001 From: DongkyunKim <134477764+dongkyun0713@users.noreply.github.com> Date: Thu, 28 Nov 2024 02:04:08 +0900 Subject: [PATCH] =?UTF-8?q?Refactor:=20=EC=B1=8C=EB=A6=B0=EC=A7=80=20?= =?UTF-8?q?=EB=B0=98=ED=99=98=20=ED=83=80=EC=9E=85=EC=97=90=20=EC=B1=8C?= =?UTF-8?q?=EB=A6=B0=EC=A7=80=20=EC=9E=91=EC=84=B1=EC=9E=90=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80=20(#227)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Refactor: 리펙토링 * refactor(#217): 챌린지 블록이 시작전에 5개 이상 쌓이면 탈퇴하도록 변경 * refactor: 챌린지 반환 타입에 챌린지 작성자 추가 --- .../challenge/api/dto/response/ChallengeInfoResDto.java | 3 +++ .../challenge/api/ChallengeControllerTest.java | 9 ++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/main/java/shop/kkeujeok/kkeujeokbackend/challenge/api/dto/response/ChallengeInfoResDto.java b/src/main/java/shop/kkeujeok/kkeujeokbackend/challenge/api/dto/response/ChallengeInfoResDto.java index 92b69308..8a851ca1 100644 --- a/src/main/java/shop/kkeujeok/kkeujeokbackend/challenge/api/dto/response/ChallengeInfoResDto.java +++ b/src/main/java/shop/kkeujeok/kkeujeokbackend/challenge/api/dto/response/ChallengeInfoResDto.java @@ -13,6 +13,7 @@ @Builder public record ChallengeInfoResDto( Long challengeId, + Long authorId, String title, String contents, Category category, @@ -32,6 +33,7 @@ public record ChallengeInfoResDto( public static ChallengeInfoResDto from(Challenge challenge) { return ChallengeInfoResDto.builder() .challengeId(challenge.getId()) + .authorId(challenge.getMember().getId()) .title(challenge.getTitle()) .contents(challenge.getContents()) .category(challenge.getCategory()) @@ -54,6 +56,7 @@ public static ChallengeInfoResDto of(Challenge challenge, boolean isParticipant, Set completedMembers) { return ChallengeInfoResDto.builder() .challengeId(challenge.getId()) + .authorId(challenge.getMember().getId()) .title(challenge.getTitle()) .contents(challenge.getContents()) .category(challenge.getCategory()) diff --git a/src/test/java/shop/kkeujeok/kkeujeokbackend/challenge/api/ChallengeControllerTest.java b/src/test/java/shop/kkeujeok/kkeujeokbackend/challenge/api/ChallengeControllerTest.java index 725054b3..cdb241b7 100644 --- a/src/test/java/shop/kkeujeok/kkeujeokbackend/challenge/api/ChallengeControllerTest.java +++ b/src/test/java/shop/kkeujeok/kkeujeokbackend/challenge/api/ChallengeControllerTest.java @@ -50,6 +50,7 @@ import shop.kkeujeok.kkeujeokbackend.block.domain.Type; import shop.kkeujeok.kkeujeokbackend.challenge.api.dto.reqeust.ChallengeSaveReqDto; import shop.kkeujeok.kkeujeokbackend.challenge.api.dto.reqeust.ChallengeSearchReqDto; +import shop.kkeujeok.kkeujeokbackend.challenge.api.dto.response.ChallengeCompletedMemberInfoResDto; import shop.kkeujeok.kkeujeokbackend.challenge.api.dto.response.ChallengeInfoResDto; import shop.kkeujeok.kkeujeokbackend.challenge.api.dto.response.ChallengeListResDto; import shop.kkeujeok.kkeujeokbackend.challenge.domain.Category; @@ -179,6 +180,7 @@ void setUp(RestDocumentationContextProvider restDocumentation) { fieldWithPath("statusCode").description("상태 코드"), fieldWithPath("message").description("응답 메시지"), fieldWithPath("data.challengeId").description("챌린지 id"), + fieldWithPath("data.authorId").description("챌린지 작성자 id"), fieldWithPath("data.title").description("챌린지 제목"), fieldWithPath("data.contents").description("챌린지 내용"), fieldWithPath("data.category").description("챌린지 카테고리"), @@ -242,6 +244,7 @@ void setUp(RestDocumentationContextProvider restDocumentation) { fieldWithPath("statusCode").description("상태 코드"), fieldWithPath("message").description("응답 메시지"), fieldWithPath("data.challengeId").description("챌린지 id"), + fieldWithPath("data.authorId").description("챌린지 작성자 id"), fieldWithPath("data.title").description("챌린지 제목"), fieldWithPath("data.contents").description("챌린지 내용"), fieldWithPath("data.category").description("챌린지 카테고리"), @@ -295,6 +298,7 @@ void setUp(RestDocumentationContextProvider restDocumentation) { fieldWithPath("statusCode").description("상태 코드"), fieldWithPath("message").description("응답 메시지"), fieldWithPath("data.challengeInfoResDto[].challengeId").description("챌린지 id"), + fieldWithPath("data.challengeInfoResDto[].authorId").description("챌린지 작성자"), fieldWithPath("data.challengeInfoResDto[].title").description("챌린지 제목"), fieldWithPath("data.challengeInfoResDto[].contents").description("챌린지 내용"), fieldWithPath("data.challengeInfoResDto[].category").description("챌린지 카테고리"), @@ -360,6 +364,7 @@ void setUp(RestDocumentationContextProvider restDocumentation) { fieldWithPath("statusCode").description("상태 코드"), fieldWithPath("message").description("응답 메시지"), fieldWithPath("data.challengeInfoResDto[].challengeId").description("챌린지 id"), + fieldWithPath("data.challengeInfoResDto[].authorId").description("챌린지 작성자"), fieldWithPath("data.challengeInfoResDto[].title").description("챌린지 제목"), fieldWithPath("data.challengeInfoResDto[].contents").description("챌린지 내용"), fieldWithPath("data.challengeInfoResDto[].category").description("챌린지 카테고리"), @@ -394,6 +399,8 @@ void setUp(RestDocumentationContextProvider restDocumentation) { @DisplayName("챌린지 상세 정보 조회에 성공하면 상태코드 200 반환") void 챌린지_상세_조회에_성공하면_상태코드_200_반환() throws Exception { // given + ChallengeCompletedMemberInfoResDto challengeCompletedMemberInfoResDto = ChallengeCompletedMemberInfoResDto.from( + member); ChallengeInfoResDto response = ChallengeInfoResDto.from(challenge); given(challengeService.findById(anyString(), anyLong())) .willReturn(response); @@ -414,6 +421,7 @@ void setUp(RestDocumentationContextProvider restDocumentation) { fieldWithPath("statusCode").description("상태 코드"), fieldWithPath("message").description("응답 메시지"), fieldWithPath("data.challengeId").description("챌린지 id"), + fieldWithPath("data.authorId").description("챌린지 작성자 id"), fieldWithPath("data.title").description("챌린지 제목"), fieldWithPath("data.contents").description("챌린지 내용"), fieldWithPath("data.category").description("챌린지 카테고리"), @@ -429,7 +437,6 @@ void setUp(RestDocumentationContextProvider restDocumentation) { fieldWithPath("data.isParticipant").description("참여 여부"), fieldWithPath("data.isAuthor").description("작성자 여부"), fieldWithPath("data.completedMembers[]").description("완료한 회원 목록") - )) ) .andExpect(status().isOk());