11package com.psr.psr.chat.controller
22
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
45import com.psr.psr.global.dto.BaseResponse
56import com.psr.psr.global.jwt.UserAccount
6- import com.psr.psr.product.dto.request.CreateproductReq
77import io.swagger.v3.oas.annotations.Operation
88import io.swagger.v3.oas.annotations.Parameter
99import io.swagger.v3.oas.annotations.media.Content
@@ -17,11 +17,11 @@ import org.springframework.security.core.annotation.AuthenticationPrincipal
1717import org.springframework.web.bind.annotation.*
1818
1919@RestController
20- @RequestMapping(" /chatRooms " )
21- @Tag(name = " ChatRoom " , description = " 채팅방 API" )
20+ @RequestMapping(" /chat " )
21+ @Tag(name = " Chat " , description = " 채팅 API" )
2222@SecurityRequirement(name = " Bearer" )
23- class ChatRoomController (
24- private val chatRoomService : ChatRoomService
23+ class ChatController (
24+ private val chatService : ChatService
2525) {
2626
2727 /* *
@@ -37,11 +37,11 @@ class ChatRoomController(
3737 content = arrayOf(Content (schema = Schema (implementation = BaseResponse ::class )))
3838 )]
3939 )
40- @PostMapping(" /{orderId}" )
40+ @PostMapping(" /rooms/ {orderId}" )
4141 fun createChatRoom (@AuthenticationPrincipal userAccount : UserAccount ,
4242 @Parameter(description = " (Long) 요청 id" , example = " 1" ) @PathVariable orderId : Long
4343 ): BaseResponse <Unit > {
44- return BaseResponse (chatRoomService .createChatRoom(userAccount.getUser(), orderId))
44+ return BaseResponse (chatService .createChatRoom(userAccount.getUser(), orderId))
4545 }
4646
4747 /* *
@@ -57,11 +57,32 @@ class ChatRoomController(
5757 content = arrayOf(Content (schema = Schema (implementation = BaseResponse ::class )))
5858 )]
5959 )
60- @PatchMapping(" /{chatRoomId}" )
60+ @PatchMapping(" /rooms/ {chatRoomId}" )
6161 fun leaveChatRoom (@AuthenticationPrincipal userAccount : UserAccount ,
6262 @Parameter(description = " (Long) 채팅방 id" , example = " 1" ) @PathVariable chatRoomId : Long
6363 ): 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))
6586 }
6687
6788
0 commit comments