| | |
| | | package com.xiaopeng.pushMessage.webSocket.controller; |
| | | |
| | | import com.fasterxml.jackson.core.JsonProcessingException; |
| | | import com.fasterxml.jackson.databind.ObjectMapper; |
| | | import com.xiaopeng.api.dto.pushMessage.SendMessageDTO; |
| | | import com.xiaopeng.api.vo.TaskVO; |
| | | import com.xiaopeng.common.core.domain.R; |
| | | import com.xiaopeng.common.core.web.controller.BaseController; |
| | | import com.xiaopeng.pushMessage.webSocket.service.WebSocketUserService; |
| | |
| | | |
| | | @Autowired |
| | | private WebSocketUserService webSocketUserService; |
| | | |
| | | @Autowired ObjectMapper om; |
| | | |
| | | // ==================== 基于XpAppUser的WebSocket接口 ==================== |
| | | |
| | |
| | | return R.fail("获取在线用户列表失败: " + e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 运维工单app推送 |
| | | */ |
| | | @PostMapping("/inner/websocket/push/task") |
| | | public R<?> pushTask(@RequestBody TaskVO vo) throws JsonProcessingException { |
| | | |
| | | String handleUserId = vo.getHandleUserId(); |
| | | String msg = om.writeValueAsString(vo); |
| | | webSocketUserService.sendMessageToUser(handleUserId, msg); |
| | | return R.ok(); |
| | | |
| | | } |
| | | |
| | | } |