1
1
package com .hf .healthfriend .domain .chat .controller ;
2
2
3
3
import com .hf .healthfriend .domain .chat .constant .ChatroomListSearchCondition ;
4
+ import com .hf .healthfriend .domain .chat .controller .schema .ChatMessageListResponseSchema ;
5
+ import com .hf .healthfriend .domain .chat .dto .response .ChatMessageListResponseDto ;
4
6
import com .hf .healthfriend .domain .chat .dto .response .ChatroomListResponseDto ;
5
7
import com .hf .healthfriend .domain .chat .service .ChatService ;
6
8
import com .hf .healthfriend .global .spec .ApiBasicResponse ;
9
+ import io .swagger .v3 .oas .annotations .Operation ;
10
+ import io .swagger .v3 .oas .annotations .Parameter ;
11
+ import io .swagger .v3 .oas .annotations .enums .ParameterIn ;
12
+ import io .swagger .v3 .oas .annotations .media .Content ;
13
+ import io .swagger .v3 .oas .annotations .media .ExampleObject ;
14
+ import io .swagger .v3 .oas .annotations .media .Schema ;
15
+ import io .swagger .v3 .oas .annotations .responses .ApiResponse ;
7
16
import lombok .RequiredArgsConstructor ;
8
17
import org .springframework .http .HttpStatus ;
9
18
import org .springframework .http .ResponseEntity ;
@@ -28,4 +37,117 @@ public ResponseEntity<ApiBasicResponse<List<ChatroomListResponseDto>>> getChatro
28
37
ApiBasicResponse .of (this .chatService .getChatroomList (participantId , searchCondition , page , pageSize ), HttpStatus .OK )
29
38
);
30
39
}
40
+
41
+ @ GetMapping ("/chatrooms/{chatroomId}/chat-messages" )
42
+ @ Operation (
43
+ summary = "채팅 메시지 불러오기" ,
44
+ parameters = {
45
+ @ Parameter (
46
+ name = "chatroomId" ,
47
+ in = ParameterIn .PATH ,
48
+ description = "채팅 목록을 가져올 채팅방의 ID" ,
49
+ required = true
50
+ ),
51
+ @ Parameter (
52
+ name = "page" ,
53
+ in = ParameterIn .QUERY ,
54
+ description = "채팅 목록 페이지. 생략 시 1"
55
+ ),
56
+ @ Parameter (
57
+ name = "pageSize" ,
58
+ in = ParameterIn .QUERY ,
59
+ description = "한 번에 가져올 채팅의 개수. default: 50"
60
+ )
61
+ },
62
+ responses = {
63
+ @ ApiResponse (
64
+ description = "채팅 목록 가져오기 성공" ,
65
+ responseCode = "200" ,
66
+ content = @ Content (
67
+ schema = @ Schema (implementation = ChatMessageListResponseSchema .class ),
68
+ examples = @ ExampleObject ("""
69
+ {
70
+ "statusCode": 200,
71
+ "statusCodeSeries": 2,
72
+ "content": {
73
+ "isFirst": true,
74
+ "isLast": false,
75
+ "page": 1,
76
+ "pageSize": 5,
77
+ "chatMessages": [
78
+ {
79
+ "chatMessageId": 456,
80
+ "senderId": 120,
81
+ "creationTime": "2025-01-07T12:00:00.000Z",
82
+ "lastModified": "2025-01-07T12:00:00.000Z",
83
+ "chatMessageType": "TEXT",
84
+ "content": {
85
+ "text": "Good Bye!"
86
+ },
87
+ "read": true
88
+ },
89
+ {
90
+ "chatMessageId": 447,
91
+ "senderId": 120,
92
+ "creationTime": "2025-01-07T11:30:00.000Z",
93
+ "lastModified": "2025-01-07T11:30:00.000Z",
94
+ "chatMessageType": "TEXT",
95
+ "content": {
96
+ "text": "Hello!"
97
+ },
98
+ "read": true
99
+ },
100
+ {
101
+ "chatMessageId": 420,
102
+ "senderId": 80,
103
+ "creationTime": "2025-01-07T11:27:00.000Z",
104
+ "lastModified": "2025-01-07T11:27:00.000Z",
105
+ "chatMessageType": "MATCHING_RESPONSE",
106
+ "content": {
107
+ "matchingResponseType": "ACCEPTED",
108
+ "cancelMessage": null
109
+ },
110
+ "read": true
111
+ },
112
+ {
113
+ "chatMessageId": 415,
114
+ "senderId": 120,
115
+ "creationTime": "2025-01-07T11:00:00.000Z",
116
+ "lastModified": "2025-01-07T11:00:00.000Z",
117
+ "chatMessageType": "MATCHING_REQUEST",
118
+ "content": {
119
+ "meetingTime": "2025-01-08T18:00:00.000Z",
120
+ "meetingPlace": "스포애니 당산점",
121
+ "meetingPlaceAddress": "서울시 영등포구 당산역"
122
+ },
123
+ "read": true
124
+ },
125
+ {
126
+ "chatMessageId": 410,
127
+ "senderId": 80,
128
+ "creationTime": "2025-01-07T10:00:00.000Z",
129
+ "lastModified": "2025-01-07T10:00:00.000Z",
130
+ "chatMessageType": "TEXT",
131
+ "content": {
132
+ "TEXT": "매칭 신청 걸어주세요"
133
+ },
134
+ "read": true
135
+ }
136
+ ]
137
+ }
138
+ }
139
+ """ )
140
+ )
141
+ )
142
+ }
143
+ )
144
+ public ResponseEntity <ApiBasicResponse <ChatMessageListResponseDto >> getChatMessages (
145
+ @ PathVariable ("chatroomId" ) Long chatroomId ,
146
+ @ RequestParam (value = "page" , required = false ) Integer page ,
147
+ @ RequestParam (value = "pageSize" , required = false ) Integer pageSize ) {
148
+ ChatMessageListResponseDto result = this .chatService .getChatMessages (chatroomId , page , pageSize );
149
+ return ResponseEntity .ok (
150
+ ApiBasicResponse .of (result , HttpStatus .OK )
151
+ );
152
+ }
31
153
}
0 commit comments