-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fe97bd8
commit 4151bcc
Showing
5 changed files
with
88 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
src/main/java/com/example/wonderwoman/chatting/response/ChatRoomListDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package com.example.wonderwoman.chatting.response; | ||
|
||
import com.example.wonderwoman.delivery.entity.Building; | ||
import com.example.wonderwoman.chatting.entity.ChatRoom; | ||
import com.example.wonderwoman.delivery.entity.PostStatus; | ||
import com.example.wonderwoman.delivery.entity.SanitarySize; | ||
import com.example.wonderwoman.member.entity.Member; | ||
import com.example.wonderwoman.member.entity.School; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
import java.time.format.DateTimeFormatter; | ||
import java.util.List; | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
@Builder | ||
public class ChatRoomListDto { | ||
|
||
private String id; | ||
|
||
private Long userId; | ||
|
||
private String userNickName; | ||
|
||
private String userImg; | ||
|
||
private PostStatus postStatus; | ||
|
||
private School school; | ||
|
||
private List<Building> building; | ||
|
||
private SanitarySize sanitarySize; | ||
|
||
private int sanitaryNum; | ||
|
||
private String createdAt; | ||
|
||
private String updatedAt; | ||
|
||
private String lastMessage; | ||
|
||
private boolean isWriter; | ||
|
||
public static ChatRoomListDto of(ChatRoom chatRoom, Member member, boolean isWriter) { | ||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy년 M월 d일 HH:mm"); | ||
String createdAtString = chatRoom.getJoinedAt().format(formatter); | ||
String updatedAtString = chatRoom.getUpdatedAt().format(formatter); | ||
|
||
return ChatRoomListDto.builder() | ||
.id(chatRoom.getId()) | ||
.userId(member.getId()) | ||
.userNickName(member.getNickname()) | ||
.userImg(member.getImgUrl()) | ||
.postStatus(chatRoom.getDeliveryPost().getPostStatus()) | ||
.school(chatRoom.getDeliveryPost().getSchool()) | ||
.building(chatRoom.getDeliveryPost().getBuilding()) | ||
.sanitarySize(chatRoom.getDeliveryPost().getSanitarySize()) | ||
.sanitaryNum(chatRoom.getDeliveryPost().getSanitaryNum()) | ||
.createdAt(createdAtString) | ||
.updatedAt(updatedAtString) | ||
.lastMessage(chatRoom.getLastMessage()) | ||
.isWriter(isWriter) | ||
.build(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters