|
|
|
@ -3,9 +3,6 @@ package com.huoran.nakadai.controller; |
|
|
|
|
import com.huoran.common.response.R; |
|
|
|
|
import com.huoran.common.utils.TokenUtils; |
|
|
|
|
import com.huoran.nakadai.service.MessageService; |
|
|
|
|
import com.huoran.websocket.model.dto.WebsocketMsgDTO; |
|
|
|
|
import com.huoran.websocket.model.vo.SendMsgVO; |
|
|
|
|
import com.huoran.websocket.service.WebsocketService; |
|
|
|
|
import io.swagger.annotations.Api; |
|
|
|
|
import io.swagger.annotations.ApiOperation; |
|
|
|
|
import io.swagger.annotations.ApiParam; |
|
|
|
@ -28,38 +25,38 @@ public class MessageController { |
|
|
|
|
@Autowired |
|
|
|
|
private MessageService messageService; |
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
private WebsocketService webSocketService; |
|
|
|
|
|
|
|
|
|
@ApiOperation(value = "所有在线用户接收消息通知",response = SendMsgVO.class) |
|
|
|
|
@PostMapping("/refreshPageNotification") |
|
|
|
|
public void refreshPageNotification( |
|
|
|
|
@ApiParam(name = "username", value = "发送者名称", required = false) |
|
|
|
|
@RequestParam(required = false) String username, |
|
|
|
|
@ApiParam(name = "to", value = "发给谁(默认发送给所有在线用户)", required = false) |
|
|
|
|
@RequestParam(required = false) String to, |
|
|
|
|
@ApiParam(name = "content", value = "消息通知", required = false) |
|
|
|
|
@RequestParam(required = false) String content) { |
|
|
|
|
WebsocketMsgDTO websocketMsgDTO = new WebsocketMsgDTO(); |
|
|
|
|
websocketMsgDTO.setForm("系统消息"); |
|
|
|
|
if (StringUtils.isEmpty(username)){ |
|
|
|
|
websocketMsgDTO.setUsername("系统通知机器人"); |
|
|
|
|
}else { |
|
|
|
|
websocketMsgDTO.setUsername(username); |
|
|
|
|
} |
|
|
|
|
if (StringUtils.isEmpty(to)){ |
|
|
|
|
websocketMsgDTO.setTo("all"); |
|
|
|
|
}else { |
|
|
|
|
websocketMsgDTO.setTo(to); |
|
|
|
|
} |
|
|
|
|
if (StringUtils.isEmpty(content)){ |
|
|
|
|
websocketMsgDTO.setContent("refresh"); |
|
|
|
|
}else { |
|
|
|
|
websocketMsgDTO.setContent(content); |
|
|
|
|
} |
|
|
|
|
websocketMsgDTO.setExtras(null); |
|
|
|
|
webSocketService.send(websocketMsgDTO); |
|
|
|
|
} |
|
|
|
|
// @Autowired
|
|
|
|
|
// private WebsocketService webSocketService;
|
|
|
|
|
|
|
|
|
|
// @ApiOperation(value = "所有在线用户接收消息通知",response = SendMsgVO.class)
|
|
|
|
|
// @PostMapping("/refreshPageNotification")
|
|
|
|
|
// public void refreshPageNotification(
|
|
|
|
|
// @ApiParam(name = "username", value = "发送者名称", required = false)
|
|
|
|
|
// @RequestParam(required = false) String username,
|
|
|
|
|
// @ApiParam(name = "to", value = "发给谁(默认发送给所有在线用户)", required = false)
|
|
|
|
|
// @RequestParam(required = false) String to,
|
|
|
|
|
// @ApiParam(name = "content", value = "消息通知", required = false)
|
|
|
|
|
// @RequestParam(required = false) String content) {
|
|
|
|
|
// WebsocketMsgDTO websocketMsgDTO = new WebsocketMsgDTO();
|
|
|
|
|
// websocketMsgDTO.setForm("系统消息");
|
|
|
|
|
// if (StringUtils.isEmpty(username)){
|
|
|
|
|
// websocketMsgDTO.setUsername("系统通知机器人");
|
|
|
|
|
// }else {
|
|
|
|
|
// websocketMsgDTO.setUsername(username);
|
|
|
|
|
// }
|
|
|
|
|
// if (StringUtils.isEmpty(to)){
|
|
|
|
|
// websocketMsgDTO.setTo("all");
|
|
|
|
|
// }else {
|
|
|
|
|
// websocketMsgDTO.setTo(to);
|
|
|
|
|
// }
|
|
|
|
|
// if (StringUtils.isEmpty(content)){
|
|
|
|
|
// websocketMsgDTO.setContent("refresh");
|
|
|
|
|
// }else {
|
|
|
|
|
// websocketMsgDTO.setContent(content);
|
|
|
|
|
// }
|
|
|
|
|
// websocketMsgDTO.setExtras(null);
|
|
|
|
|
// webSocketService.send(websocketMsgDTO);
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 发送指定的用户队列 |
|
|
|
|