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 #164] 채팅 요청 상세 조회 API 응답값 추가 #166

Merged
merged 4 commits into from
Dec 8, 2024
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 @@ -7,6 +7,11 @@ public record ChatInquiryDetailResponse(
String inquiryMessage,
String inquiryStatus,
boolean isInquirer,
MemberInfo chatPartner
int memberCredit,
Long questionPostId,
String targetJobGroup,
String title,
MemberInfo chatPartner,
String createdAt
) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,27 @@ public static CreateChatInquiryResponse toCreateChatInquiryResponse(

public static ChatInquiryDetailResponse toChatInquiryDetailResponse(
ChatInquiry chatInquiry,
Member member,
Member chatPartner,
boolean isInquirer
) {
return new ChatInquiryDetailResponse(chatInquiry.getId(),
QuestionPost questionPost = chatInquiry.getQuestionPost();
return new ChatInquiryDetailResponse(
chatInquiry.getId(),
chatInquiry.getMessage(),
chatInquiry.getStatus().getLabel(),
isInquirer,
member.getCredit(),
questionPost.getId(),
questionPost.getJobGroup().toString(),
questionPost.getTitle(),
new MemberInfo(
chatPartner.getId(),
chatPartner.getNickname(),
chatPartner.getJobGroup().getLabel(),
chatPartner.getProfileImageNo()
)
),
chatInquiry.getCreatedAt().toString()
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ public record CreateChatInquiryResponse(
Long chatInquiryId,
String inquiryMessage,
String inquiryStatus,
int credit,
int memberCredit,
MemberInfo chatPartner
) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ public ChatInquiryDetailResponse getChatInquiryById(Long chatInquiryId, Member m

return ChatInquiryMapper.toChatInquiryDetailResponse(
chatInquiry,
member,
chatInquiry.getChatPartner(member),
chatInquiry.isInquirer(member)
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,9 @@ void createChatInquiry() throws Exception {
.content(toJson(request))
.contentType(APPLICATION_JSON))
.andExpect(status().isOk())
.andExpect(jsonPath("$.chatPartner.memberId").value(answerer.getId()))
.andExpect(jsonPath("$.inquiryStatus").value(InquiryStatus.PENDING.getLabel()))
.andExpect(jsonPath("$.credit").value(previousCredit - CHAT_REWARD))
.andExpect(jsonPath("$.memberCredit").value(previousCredit - CHAT_REWARD))
.andDo(MockMvcResultHandlers.print());
}

Expand All @@ -94,6 +95,7 @@ void getChatInquiryById() throws Exception {
ChatInquiry chatInquiry = chatInquiryRepository.save(
ChatInquiryFixture.chatInquiry(questionPost, loginMember, chatPartner, INQUIRY_MESSAGE)
);
memberRepository.save(loginMember); // credit 변경사항 flush

//when & then
mockMvc.perform(get("/api/chat/inquiries/{chatInquiryId}", chatInquiry.getId())
Expand All @@ -107,8 +109,12 @@ void getChatInquiryById() throws Exception {
.value(chatPartner.getId()))
.andExpect(jsonPath("$.isInquirer")
.value(chatInquiry.getInquirer().equals(loginMember)))
.andExpect(jsonPath("$.memberCredit")
.value(loginMember.getCredit()))
.andExpect(jsonPath("$.inquiryStatus")
.value(InquiryStatus.PENDING.getLabel()));
.value(InquiryStatus.PENDING.getLabel()))
.andExpect(jsonPath("$.questionPostId")
.value(chatInquiry.getQuestionPost().getId()));
}

@DisplayName("[회원의 채팅 요청 목록을 조회할 수 있다.]")
Expand Down
Loading