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