1
1
package com.psr.psr.chat.controller
2
2
3
- import com.psr.psr.chat.service.ChatRoomService
3
+ import com.psr.psr.chat.dto.request.ChatMessageReq
4
+ import com.psr.psr.chat.service.ChatService
4
5
import com.psr.psr.global.dto.BaseResponse
5
6
import com.psr.psr.global.jwt.UserAccount
6
- import com.psr.psr.product.dto.request.CreateproductReq
7
7
import io.swagger.v3.oas.annotations.Operation
8
8
import io.swagger.v3.oas.annotations.Parameter
9
9
import io.swagger.v3.oas.annotations.media.Content
@@ -17,11 +17,11 @@ import org.springframework.security.core.annotation.AuthenticationPrincipal
17
17
import org.springframework.web.bind.annotation.*
18
18
19
19
@RestController
20
- @RequestMapping(" /chatRooms " )
21
- @Tag(name = " ChatRoom " , description = " 채팅방 API" )
20
+ @RequestMapping(" /chat " )
21
+ @Tag(name = " Chat " , description = " 채팅 API" )
22
22
@SecurityRequirement(name = " Bearer" )
23
- class ChatRoomController (
24
- private val chatRoomService : ChatRoomService
23
+ class ChatController (
24
+ private val chatService : ChatService
25
25
) {
26
26
27
27
/* *
@@ -37,11 +37,11 @@ class ChatRoomController(
37
37
content = arrayOf(Content (schema = Schema (implementation = BaseResponse ::class )))
38
38
)]
39
39
)
40
- @PostMapping(" /{orderId}" )
40
+ @PostMapping(" /rooms/ {orderId}" )
41
41
fun createChatRoom (@AuthenticationPrincipal userAccount : UserAccount ,
42
42
@Parameter(description = " (Long) 요청 id" , example = " 1" ) @PathVariable orderId : Long
43
43
): BaseResponse <Unit > {
44
- return BaseResponse (chatRoomService .createChatRoom(userAccount.getUser(), orderId))
44
+ return BaseResponse (chatService .createChatRoom(userAccount.getUser(), orderId))
45
45
}
46
46
47
47
/* *
@@ -57,11 +57,32 @@ class ChatRoomController(
57
57
content = arrayOf(Content (schema = Schema (implementation = BaseResponse ::class )))
58
58
)]
59
59
)
60
- @PatchMapping(" /{chatRoomId}" )
60
+ @PatchMapping(" /rooms/ {chatRoomId}" )
61
61
fun leaveChatRoom (@AuthenticationPrincipal userAccount : UserAccount ,
62
62
@Parameter(description = " (Long) 채팅방 id" , example = " 1" ) @PathVariable chatRoomId : Long
63
63
): BaseResponse <Unit > {
64
- return BaseResponse (chatRoomService.leaveChatRoom(userAccount.getUser(), chatRoomId));
64
+ return BaseResponse (chatService.leaveChatRoom(userAccount.getUser(), chatRoomId));
65
+ }
66
+
67
+ /* *
68
+ * 메시지 전송
69
+ */
70
+ @Operation(summary = " 메시지 전송(박소정)" , description = " 채팅방에 메시지를 전송한다." )
71
+ @ApiResponses(
72
+ value = [
73
+ ApiResponse (responseCode = " 200" , description = " 요청에 성공했습니다." ),
74
+ ApiResponse (
75
+ responseCode = " 404" ,
76
+ description = " 해당 요청을 찾을 수 없습니다." ,
77
+ content = arrayOf(Content (schema = Schema (implementation = BaseResponse ::class )))
78
+ )]
79
+ )
80
+ @PostMapping(" /{chatRoomId}" )
81
+ fun createChatMessage (@AuthenticationPrincipal userAccount : UserAccount ,
82
+ @Parameter(description = " (Long) 채팅방 id" , example = " 1" ) @PathVariable chatRoomId : Long ,
83
+ @RequestBody @Valid request : ChatMessageReq
84
+ ): BaseResponse <Unit > {
85
+ return BaseResponse (chatService.createChatMessage(userAccount.getUser(), chatRoomId, request))
65
86
}
66
87
67
88
0 commit comments