diff --git a/src/main/java/com/dnd/gongmuin/chat_inquiry/dto/ChatInquiryDetailResponse.java b/src/main/java/com/dnd/gongmuin/chat_inquiry/dto/ChatInquiryDetailResponse.java index 08aba1a3..0b686d4b 100644 --- a/src/main/java/com/dnd/gongmuin/chat_inquiry/dto/ChatInquiryDetailResponse.java +++ b/src/main/java/com/dnd/gongmuin/chat_inquiry/dto/ChatInquiryDetailResponse.java @@ -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 ) { } diff --git a/src/main/java/com/dnd/gongmuin/chat_inquiry/dto/ChatInquiryMapper.java b/src/main/java/com/dnd/gongmuin/chat_inquiry/dto/ChatInquiryMapper.java index ef1c5278..691c0eda 100644 --- a/src/main/java/com/dnd/gongmuin/chat_inquiry/dto/ChatInquiryMapper.java +++ b/src/main/java/com/dnd/gongmuin/chat_inquiry/dto/ChatInquiryMapper.java @@ -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() ); } diff --git a/src/main/java/com/dnd/gongmuin/chat_inquiry/dto/CreateChatInquiryResponse.java b/src/main/java/com/dnd/gongmuin/chat_inquiry/dto/CreateChatInquiryResponse.java index 0a5dd812..8da2814f 100644 --- a/src/main/java/com/dnd/gongmuin/chat_inquiry/dto/CreateChatInquiryResponse.java +++ b/src/main/java/com/dnd/gongmuin/chat_inquiry/dto/CreateChatInquiryResponse.java @@ -6,7 +6,7 @@ public record CreateChatInquiryResponse( Long chatInquiryId, String inquiryMessage, String inquiryStatus, - int credit, + int memberCredit, MemberInfo chatPartner ) { } diff --git a/src/main/java/com/dnd/gongmuin/chat_inquiry/service/ChatInquiryService.java b/src/main/java/com/dnd/gongmuin/chat_inquiry/service/ChatInquiryService.java index d51725b5..0ef669c3 100644 --- a/src/main/java/com/dnd/gongmuin/chat_inquiry/service/ChatInquiryService.java +++ b/src/main/java/com/dnd/gongmuin/chat_inquiry/service/ChatInquiryService.java @@ -77,6 +77,7 @@ public ChatInquiryDetailResponse getChatInquiryById(Long chatInquiryId, Member m return ChatInquiryMapper.toChatInquiryDetailResponse( chatInquiry, + member, chatInquiry.getChatPartner(member), chatInquiry.isInquirer(member) ); diff --git a/src/test/java/com/dnd/gongmuin/chat_inquiry/controller/ChatInquiryControllerTest.java b/src/test/java/com/dnd/gongmuin/chat_inquiry/controller/ChatInquiryControllerTest.java index 038f9c93..cc98553c 100644 --- a/src/test/java/com/dnd/gongmuin/chat_inquiry/controller/ChatInquiryControllerTest.java +++ b/src/test/java/com/dnd/gongmuin/chat_inquiry/controller/ChatInquiryControllerTest.java @@ -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()); } @@ -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()) @@ -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("[회원의 채팅 요청 목록을 조회할 수 있다.]")