Skip to content

Commit 4f9ef8b

Browse files
committed
Feat: 개인 채팅 관련 DTO 생성
1 parent e6b5fc6 commit 4f9ef8b

File tree

4 files changed

+134
-0
lines changed

4 files changed

+134
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package com.back.domain.chat.dm.dto;
2+
3+
import java.time.LocalDateTime;
4+
import java.util.List;
5+
6+
public record ConversationListResponse(
7+
List<ConversationDto> conversations
8+
) {
9+
10+
// 개별 대화 정보 DTO
11+
public record ConversationDto(
12+
Long userId,
13+
String nickname,
14+
String profileImageUrl,
15+
LastMessageDto lastMessage,
16+
Integer unreadCount
17+
) {}
18+
19+
// 마지막 메시지 정보 DTO
20+
public record LastMessageDto(
21+
String content,
22+
LocalDateTime createdAt,
23+
Boolean isRead
24+
) {}
25+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package com.back.domain.chat.dm.dto;
2+
3+
import java.time.LocalDateTime;
4+
import java.util.List;
5+
6+
public record PrivateMessageHistoryResponse(
7+
List<PrivateMessageDto> content,
8+
PageableDto pageable
9+
) {
10+
11+
// 개인 메시지 정보 DTO
12+
public record PrivateMessageDto(
13+
Long messageId,
14+
Long fromUserId,
15+
Long toUserId,
16+
String content,
17+
String messageType,
18+
PrivateMessageResponse.AttachmentDto attachment,
19+
LocalDateTime createdAt,
20+
Boolean isRead
21+
) {}
22+
23+
// 페이징 정보 DTO
24+
public record PageableDto(
25+
Integer page,
26+
Integer size,
27+
Boolean hasNext
28+
) {}
29+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package com.back.domain.chat.dm.dto;
2+
3+
import jakarta.validation.constraints.NotBlank;
4+
import jakarta.validation.constraints.NotNull;
5+
6+
public record PrivateMessageRequest(
7+
@NotNull(message = "수신자 ID는 필수입니다")
8+
Long toUserId,
9+
10+
@NotBlank(message = "메시지 내용은 필수입니다")
11+
String content,
12+
13+
String messageType, // TEXT, IMAGE, FILE 등 (기본값: TEXT)
14+
15+
Long attachmentId // 첨부파일 ID (선택사항)
16+
) {
17+
18+
// 기본값 처리를 위한 정적 팩토리 메서드
19+
public static PrivateMessageRequest of(Long toUserId, String content) {
20+
return new PrivateMessageRequest(toUserId, content, "TEXT", null);
21+
}
22+
23+
// messageType 기본값 처리
24+
public String messageType() {
25+
return messageType != null ? messageType : "TEXT";
26+
}
27+
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
package com.back.domain.chat.dm.dto;
2+
3+
import java.time.LocalDateTime;
4+
5+
public record PrivateMessageResponse(
6+
Long messageId,
7+
Long fromUserId,
8+
Long toUserId,
9+
String fromNickname,
10+
String fromProfileImageUrl,
11+
String content,
12+
String messageType,
13+
AttachmentDto attachment,
14+
LocalDateTime createdAt
15+
) {
16+
17+
/**
18+
* 첨부파일 정보 DTO
19+
*/
20+
public record AttachmentDto(
21+
Long id,
22+
String originalName,
23+
String url,
24+
Long size,
25+
String mimeType
26+
) {}
27+
28+
/**
29+
* 텍스트 메시지 응답 생성 헬퍼 메서드
30+
*/
31+
public static PrivateMessageResponse createTextMessage(
32+
Long messageId,
33+
Long fromUserId,
34+
Long toUserId,
35+
String fromNickname,
36+
String fromProfileImageUrl,
37+
String content,
38+
LocalDateTime createdAt) {
39+
40+
return new PrivateMessageResponse(
41+
messageId,
42+
fromUserId,
43+
toUserId,
44+
fromNickname,
45+
fromProfileImageUrl,
46+
content,
47+
"TEXT",
48+
null, // attachment
49+
createdAt
50+
);
51+
}
52+
}
53+

0 commit comments

Comments
 (0)