forked from WeblingCafe/coffee_backend
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat : Order 도메인 WebSocket 알림 컨트롤러 구현
- 주문 생성, 주문 완료, 주문 취소, 유저에 의한 주문 취소
- Loading branch information
Showing
4 changed files
with
76 additions
and
23 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
15 changes: 0 additions & 15 deletions
15
src/main/java/webling/coffee/backend/domain/order/controller/AlertSocketController.java
This file was deleted.
Oops, something went wrong.
63 changes: 63 additions & 0 deletions
63
src/main/java/webling/coffee/backend/domain/order/controller/OrderAlertController.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,63 @@ | ||
package webling.coffee.backend.domain.order.controller; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.messaging.handler.annotation.DestinationVariable; | ||
import org.springframework.messaging.handler.annotation.MessageMapping; | ||
import org.springframework.messaging.handler.annotation.Payload; | ||
import org.springframework.messaging.handler.annotation.SendTo; | ||
import org.springframework.messaging.simp.SimpMessageSendingOperations; | ||
import org.springframework.stereotype.Controller; | ||
import webling.coffee.backend.domain.order.dto.request.OrderRequestDto; | ||
import webling.coffee.backend.domain.order.service.OrderFacade; | ||
import webling.coffee.backend.global.responses.success.codes.OrderSuccessCode; | ||
import webling.coffee.backend.global.responses.success.response.SuccessResponse; | ||
|
||
@Controller | ||
@RequiredArgsConstructor | ||
public class OrderAlertController { | ||
|
||
private final SimpMessageSendingOperations messagingTemplate; | ||
private final OrderFacade orderFacade; | ||
|
||
/** | ||
* 주문 들어갈 때 바리스타에게 웹소켓 통해 주문 생성 알림 | ||
*/ | ||
|
||
@MessageMapping("/alert/order") | ||
@SendTo("/topic/barista") | ||
public ResponseEntity<SuccessResponse> orderAlert (@Payload OrderRequestDto.OrderCreateAlert request) { | ||
|
||
|
||
return SuccessResponse.toResponseEntity( | ||
OrderSuccessCode.CREATE | ||
); | ||
} | ||
|
||
/** | ||
* 주문 완료시 유저에게 웹소켓 통한 알림 | ||
* @param userId | ||
*/ | ||
@MessageMapping("/alert/order/complete/{userId}") | ||
public void orderCompleted(@DestinationVariable("userId") Long userId) { | ||
messagingTemplate.convertAndSend("/topic/" + userId, "alarm socket connection completed."); | ||
} | ||
|
||
/** | ||
* 주문 취소 (by 바리스타) 유저에게 웹소켓 통한 알림 | ||
* @param userId | ||
*/ | ||
@MessageMapping("/alert/order/cancel/{userId}") | ||
public void orderCancelByBarista(@DestinationVariable("userId") Long userId) { | ||
messagingTemplate.convertAndSend("/topic/" + userId, "alarm socket connection completed."); | ||
} | ||
|
||
/** | ||
* 주문 취소 (by 유저) 바리스타에게 웹소켓 통한 알림 | ||
*/ | ||
@MessageMapping("/alert/order/me/cancel") | ||
@SendTo("/topic/barista") | ||
public void orderCancelByUser() { | ||
} | ||
|
||
} |
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