Skip to content

Commit

Permalink
Refactor: 챌린지 반환 타입에 챌린지 작성자 추가 (#227)
Browse files Browse the repository at this point in the history
* Refactor: 리펙토링

* refactor(#217): 챌린지 블록이 시작전에 5개 이상 쌓이면 탈퇴하도록 변경

* refactor: 챌린지 반환 타입에 챌린지 작성자 추가
  • Loading branch information
dongkyun0713 authored Nov 27, 2024
1 parent b0e1cd5 commit 8fecf29
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
@Builder
public record ChallengeInfoResDto(
Long challengeId,
Long authorId,
String title,
String contents,
Category category,
Expand All @@ -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())
Expand All @@ -54,6 +56,7 @@ public static ChallengeInfoResDto of(Challenge challenge, boolean isParticipant,
Set<ChallengeCompletedMemberInfoResDto> completedMembers) {
return ChallengeInfoResDto.builder()
.challengeId(challenge.getId())
.authorId(challenge.getMember().getId())
.title(challenge.getTitle())
.contents(challenge.getContents())
.category(challenge.getCategory())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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("챌린지 카테고리"),
Expand Down Expand Up @@ -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("챌린지 카테고리"),
Expand Down Expand Up @@ -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("챌린지 카테고리"),
Expand Down Expand Up @@ -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("챌린지 카테고리"),
Expand Down Expand Up @@ -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);
Expand All @@ -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("챌린지 카테고리"),
Expand All @@ -429,7 +437,6 @@ void setUp(RestDocumentationContextProvider restDocumentation) {
fieldWithPath("data.isParticipant").description("참여 여부"),
fieldWithPath("data.isAuthor").description("작성자 여부"),
fieldWithPath("data.completedMembers[]").description("완료한 회원 목록")

))
)
.andExpect(status().isOk());
Expand Down

0 comments on commit 8fecf29

Please sign in to comment.