Skip to content

Commit

Permalink
[feat #164] 채팅 요청 상세 조회 API 응답값 추가 (#166)
Browse files Browse the repository at this point in the history
* [feat] : 채팅 요청 상세조회에 질문글, 크레딧 정보 포함

* [feat] : 채팅 요청 생성 응답 -> 크레딧 필드명 변경

* [test] : 응답 추가 및 필드명 변경 -> 테스트 반영

* [test] : createdAt 검증 제외
  • Loading branch information
hyun2371 authored Dec 8, 2024
1 parent 8e0d75f commit 769d5c7
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 6 deletions.
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

0 comments on commit 769d5c7

Please sign in to comment.