Skip to content

Commit

Permalink
[style] : 코드 리포멧팅
Browse files Browse the repository at this point in the history
  • Loading branch information
hyun2371 committed Sep 27, 2024
1 parent 9a9633d commit 310abaa
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@

import com.dnd.gongmuin.question_post.dto.response.MemberInfo;

public record ChatRoomSimpleResponse (
public record ChatRoomSimpleResponse(
Long chatRoomId,
MemberInfo chatPartner,
String latestMessage,
String messageType,
String messageCreatedAt
){}
) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
@RequiredArgsConstructor
public class ChatRoomQueryRepositoryImpl implements ChatRoomQueryRepository {
private final JPAQueryFactory queryFactory;

public List<ChatRoomInfo> getChatRoomsByMember(Member member) {
return queryFactory
.select(new QChatRoomInfo(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,18 +85,21 @@ public List<ChatRoomSimpleResponse> getChatRoomsByMember(Member member) {
.map(ChatRoomInfo::chatRoomId)
.toList();
// 각 채팅방 최근 메시지 정보
List<LatestChatMessage> latestChatMessages = chatMessageQueryRepository.findLatestChatByChatRoomIds(chatRoomIds);
List<LatestChatMessage> latestChatMessages = chatMessageQueryRepository.findLatestChatByChatRoomIds(
chatRoomIds);
// <chatRoomId, LatestMessage> -> 순서 보장 x
Map<Long, LatestChatMessage> messageMap = latestChatMessages.stream()
.collect(Collectors.toMap(LatestChatMessage::chatRoomId, message -> message));
// 최신순 정렬
return chatRoomInfos.stream()
.sorted(Comparator.comparing((ChatRoomInfo info) -> messageMap.get(info.chatRoomId()).createdAt()).reversed())
.sorted(
Comparator.comparing((ChatRoomInfo info) -> messageMap.get(info.chatRoomId()).createdAt()).reversed())
.map(chatRoomInfo -> {
LatestChatMessage latestMessage = messageMap.get(chatRoomInfo.chatRoomId());
return new ChatRoomSimpleResponse(
chatRoomInfo.chatRoomId(),
new MemberInfo(chatRoomInfo.partnerId(), chatRoomInfo.partnerNickname(), chatRoomInfo.partnerJobGroup(), chatRoomInfo.partnerProfileImageNo()),
new MemberInfo(chatRoomInfo.partnerId(), chatRoomInfo.partnerNickname(),
chatRoomInfo.partnerJobGroup(), chatRoomInfo.partnerProfileImageNo()),
latestMessage.content(),
latestMessage.type(),
latestMessage.createdAt().toString()
Expand Down
20 changes: 10 additions & 10 deletions src/main/java/com/dnd/gongmuin/member/domain/Member.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,6 @@ private Member(String nickname, String socialName, JobGroup jobGroup, JobCategor
this.role = role;
}

@Override
public String toString() {
return "MEMBER INFO{" +
"id=" + id +
", role='" + role + '\'' +
", jobGroup=" + jobGroup +
", socialEmail='" + socialEmail + '\'' +
'}';
}

public static Member of(String socialName, String socialEmail, int credit) {
return Member.builder()
.socialName(socialName)
Expand Down Expand Up @@ -103,6 +93,16 @@ public static Member of(String nickname, String socialName, JobGroup jobGroup, J
.build();
}

@Override
public String toString() {
return "MEMBER INFO{" +
"id=" + id +
", role='" + role + '\'' +
", jobGroup=" + jobGroup +
", socialEmail='" + socialEmail + '\'' +
'}';
}

public void updateSocialEmail(String socialEmail) {
this.socialEmail = socialEmail;
}
Expand Down

0 comments on commit 310abaa

Please sign in to comment.