|
|
|
@ -1,22 +1,24 @@ |
|
|
|
|
package com.msg.controller; |
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
|
import com.hai.common.exception.ErrorCode; |
|
|
|
|
import com.hai.common.exception.ErrorHelp; |
|
|
|
|
import com.hai.common.exception.SysCode; |
|
|
|
|
import com.hai.common.utils.ResponseMsgUtil; |
|
|
|
|
import com.hai.model.ResponseData; |
|
|
|
|
import com.hai.service.WebSocket; |
|
|
|
|
import io.swagger.annotations.Api; |
|
|
|
|
import io.swagger.annotations.ApiOperation; |
|
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
|
import org.slf4j.Logger; |
|
|
|
|
import org.slf4j.LoggerFactory; |
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
|
import org.springframework.stereotype.Controller; |
|
|
|
|
import org.springframework.web.bind.annotation.RequestMapping; |
|
|
|
|
import org.springframework.web.bind.annotation.RequestMethod; |
|
|
|
|
import org.springframework.web.bind.annotation.RequestParam; |
|
|
|
|
import org.springframework.web.bind.annotation.ResponseBody; |
|
|
|
|
import org.springframework.web.bind.annotation.*; |
|
|
|
|
|
|
|
|
|
@Controller |
|
|
|
|
@RequestMapping(value = "/test") |
|
|
|
|
@Api(value = "订单接口") |
|
|
|
|
@RequestMapping(value = "/websocket") |
|
|
|
|
@Api(value = "订单推送") |
|
|
|
|
public class HighMegController { |
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
@ -24,16 +26,21 @@ public class HighMegController { |
|
|
|
|
|
|
|
|
|
private static Logger log = LoggerFactory.getLogger(HighMegController.class); |
|
|
|
|
|
|
|
|
|
@RequestMapping(value = "/websocket", method = RequestMethod.GET) |
|
|
|
|
@RequestMapping(value = "/websocket", method = RequestMethod.POST) |
|
|
|
|
@ResponseBody |
|
|
|
|
@ApiOperation(value = "websocket") |
|
|
|
|
public ResponseData websocket( |
|
|
|
|
@RequestParam(name = "userId", required = true) String userId, |
|
|
|
|
@RequestParam(name = "message", required = true) String message |
|
|
|
|
) { |
|
|
|
|
public ResponseData websocket(@RequestBody JSONObject object) { |
|
|
|
|
try { |
|
|
|
|
|
|
|
|
|
webSocket.SenderMessage(userId ,message); |
|
|
|
|
|
|
|
|
|
if (StringUtils.isBlank(object.getString("userId")) || |
|
|
|
|
StringUtils.isBlank(object.getString("message")) |
|
|
|
|
) { |
|
|
|
|
log.error("websocket error!", "参数错误"); |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
webSocket.SenderMessage(object.getString("userId") , object.getString("message")); |
|
|
|
|
return ResponseMsgUtil.success("成功"); |
|
|
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|