Skip to content

Commit

Permalink
Merge pull request #77 from kookmin-sw/feat/familarity2
Browse files Browse the repository at this point in the history
fix: sender, receiver 에 따라 faceInfoByLevel 다르게 반환
  • Loading branch information
KimChanJin97 authored May 17, 2024
2 parents 5d0a7cf + 0603bf9 commit edbc2ff
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 17 deletions.
40 changes: 28 additions & 12 deletions src/main/java/capstone/facefriend/chat/service/MessageService.java
Original file line number Diff line number Diff line change
Expand Up @@ -136,22 +136,38 @@ public void sendMessage(MessageRequest messageRequest, Long senderId) {

ChatRoomMember chatRoomMember = findChatRoomMember(chatRoom); // 영속

// getSender() 는 하트틀 보내는 사람(방 개설자)을 의미
// senderId() 는 메세지를 보내는 사람을 의미
MessageResponse messageResponse = new MessageResponse();
messageResponse.setMethod("receiveChat");
messageResponse.setRoomId(chatMessage.getChatRoom().getId());
messageResponse.setSenderId(senderId);
messageResponse.setReceiveId(receiver.getId());
messageResponse.setSenderNickname(sender.getBasicInfo().getNickname());
messageResponse.setSenderFaceInfoS3Url(chatRoomMember.getSenderFaceInfoByLevel().getGeneratedByLevelS3url()); // 수정한 부분
messageResponse.setContent(chatMessage.getContent());
messageResponse.setType("message");
messageResponse.setCreatedAt(chatMessage.getSendTime());
messageResponse.setIsRead(chatMessage.isRead());

String topic = channelTopic.getTopic();
if (chatRoomMember.getSender().equals(findMemberByid(senderId))) {
messageResponse.setMethod("receiveChat");
messageResponse.setRoomId(chatMessage.getChatRoom().getId());
messageResponse.setSenderId(senderId);
messageResponse.setReceiveId(receiver.getId());
messageResponse.setSenderNickname(sender.getBasicInfo().getNickname());
messageResponse.setSenderFaceInfoS3Url(chatRoomMember.getSenderFaceInfoByLevel().getGeneratedByLevelS3url()); // 수정한 부분
messageResponse.setContent(chatMessage.getContent());
messageResponse.setType("message");
messageResponse.setCreatedAt(chatMessage.getSendTime());
messageResponse.setIsRead(chatMessage.isRead());
}

redisTemplate.convertAndSend(topic, messageResponse);
if (chatRoomMember.getReceiver().equals(findMemberByid(senderId))) {
messageResponse.setMethod("receiveChat");
messageResponse.setRoomId(chatMessage.getChatRoom().getId());
messageResponse.setSenderId(senderId);
messageResponse.setReceiveId(receiver.getId());
messageResponse.setSenderNickname(sender.getBasicInfo().getNickname());
messageResponse.setSenderFaceInfoS3Url(chatRoomMember.getReceiverFaceInfoByLevel().getGeneratedByLevelS3url()); // 수정한 부분
messageResponse.setContent(chatMessage.getContent());
messageResponse.setType("message");
messageResponse.setCreatedAt(chatMessage.getSendTime());
messageResponse.setIsRead(chatMessage.isRead());
}

String topic = channelTopic.getTopic();
redisTemplate.convertAndSend(topic, messageResponse);
}

private ChatRoomMember findChatRoomMember(ChatRoom chatRoom) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,6 @@ public Page<ResumeHomeDetailResponse> getResumesByCategory(
@RequestParam("category") String category,
Pageable pageable
) {
return resumeService.getResumesByCategory(category, pageable);
return resumeService.getResumesByCategory(memberId, category, pageable);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
public interface ResumeRepositoryCustom {

Page<ResumeHomeDetailResponse> getResumesByGoodCombi(Long memberId, Pageable pageable); // 좋은 궁합
Page<ResumeHomeDetailResponse> getResumesByCategory(String category, Pageable pageable); // 카테고리별
Page<ResumeHomeDetailResponse> getResumesByCategory(Long memberId, String category, Pageable pageable); // 카테고리별
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,16 @@ public Page<ResumeHomeDetailResponse> getResumesByGoodCombi(Long memberId, Pagea
break;
}

Member member = findMemberById(memberId);

List<ResumeHomeDetailResponse> content = queryFactory
.select(new QResumeHomeDetailResponse(
resume.id.as("resumeId"),
resume.member.faceInfo.generatedS3url.as("thumbnailS3url")))
.from(resume)
.leftJoin(resume.member, QMember.member) // left join
.where(builder) // boolean builder
.where(resume.member.ne(member))
.orderBy(resume.id.desc())
.offset(pageable.getOffset())
.limit(pageable.getPageSize())
Expand All @@ -79,15 +82,21 @@ public Page<ResumeHomeDetailResponse> getResumesByGoodCombi(Long memberId, Pagea
return new PageImpl<>(content, pageable, total);
}



// 카테고리별 동적 쿼리
public Page<ResumeHomeDetailResponse> getResumesByCategory(String category, Pageable pageable) {
public Page<ResumeHomeDetailResponse> getResumesByCategory(Long memberId, String category, Pageable pageable) {

Member member = findMemberById(memberId);

List<ResumeHomeDetailResponse> content = queryFactory
.select(new QResumeHomeDetailResponse(
resume.id.as("resumeId"),
resume.member.faceInfo.generatedS3url.as("thumbnailS3url")))
.from(resume)
.leftJoin(resume.member, QMember.member) // left join
.where(resume.categories.contains(Resume.Category.valueOf(category)))
.where(resume.member.ne(member))
.orderBy(resume.id.desc())
.offset(pageable.getOffset())
.limit(pageable.getPageSize())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,8 @@ public Page<ResumeHomeDetailResponse> getResumesByGoodCombi(Long memberId, Pagea
return resumeRepository.getResumesByGoodCombi(memberId, pageable);
}

public Page<ResumeHomeDetailResponse> getResumesByCategory(String category, Pageable pageable) {
return resumeRepository.getResumesByCategory(category, pageable);
public Page<ResumeHomeDetailResponse> getResumesByCategory(Long memberId, String category, Pageable pageable) {
return resumeRepository.getResumesByCategory(memberId, category, pageable);
}

// 내부 로직용
Expand Down

0 comments on commit edbc2ff

Please sign in to comment.