Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feat #177] 질문 글 작성 응답 DTO 잔여 크레딧 추가 #180

Merged
merged 3 commits into from
Jan 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,8 @@ public static QuestionPostDetailResponse toQuestionPostDetailResponse(
}

public static RegisterQuestionPostResponse toRegisterQuestionPostResponse(
QuestionPost questionPost
QuestionPost questionPost, Member member
) {
Member member = questionPost.getMember();
return new RegisterQuestionPostResponse(
questionPost.getId(),
questionPost.getTitle(),
Expand All @@ -74,6 +73,7 @@ public static RegisterQuestionPostResponse toRegisterQuestionPostResponse(
member.getJobGroup().getLabel(),
member.getProfileImageNo()
),
member.getCredit(),
questionPost.getCreatedAt().toString()
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public record RegisterQuestionPostResponse(
String targetJobGroup,
String status,
MemberInfo memberInfo,
int remainingCredit,
String createdAt
) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ public RegisterQuestionPostResponse registerQuestionPost(

QuestionPost questionPost = QuestionPostMapper.toQuestionPost(request, member);
return QuestionPostMapper.toRegisterQuestionPostResponse(
questionPostRepository.save(questionPost)
questionPostRepository.save(questionPost),
member
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,13 @@ void teardown() {
@DisplayName("[질문글을 등록할 수 있다.]")
@Test
void registerQuestionPost() throws Exception {
final int reward = 2_000;

RegisterQuestionPostRequest request = new RegisterQuestionPostRequest(
"제목",
"정정기간에 여석이 있을까요?",
List.of("image1.jpg", "image2.jpg"),
2000,
reward,
"공업"
);

Expand All @@ -86,7 +88,8 @@ void registerQuestionPost() throws Exception {
.andExpect(jsonPath("$.targetJobGroup").value(request.targetJobGroup()))
.andExpect(jsonPath("$.memberInfo.memberId").value(loginMember.getId()))
.andExpect(jsonPath("$.memberInfo.nickname").value(loginMember.getNickname()))
.andExpect(jsonPath("$.memberInfo.memberJobGroup").value(loginMember.getJobGroup().getLabel()));
.andExpect(jsonPath("$.memberInfo.memberJobGroup").value(loginMember.getJobGroup().getLabel()))
.andExpect(jsonPath("$.remainingCredit").value(loginMember.getCredit() - reward));
}

@DisplayName("[보유 크레딧이 부족하면 질문글을 등록할 수 없다.]")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ void registerQuestionPost() {
() -> assertThat(response.content()).isEqualTo(request.content()),
() -> assertThat(response.reward()).isEqualTo(request.reward()),
() -> assertThat(response.targetJobGroup()).isEqualTo(request.targetJobGroup()),
() -> assertThat(response.status()).isEqualTo(QuestionPostStatus.ANSWER_WAITING.getStatus())
() -> assertThat(response.status()).isEqualTo(QuestionPostStatus.ANSWER_WAITING.getStatus()),
() -> assertThat(response.remainingCredit()).isEqualTo(member.getCredit())
);
}

Expand Down
Loading