|
|
@ -1,22 +1,24 @@ |
|
|
|
package com.msg.controller; |
|
|
|
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.common.utils.ResponseMsgUtil; |
|
|
|
import com.hai.model.ResponseData; |
|
|
|
import com.hai.model.ResponseData; |
|
|
|
import com.hai.service.WebSocket; |
|
|
|
import com.hai.service.WebSocket; |
|
|
|
import io.swagger.annotations.Api; |
|
|
|
import io.swagger.annotations.Api; |
|
|
|
import io.swagger.annotations.ApiOperation; |
|
|
|
import io.swagger.annotations.ApiOperation; |
|
|
|
|
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.slf4j.Logger; |
|
|
|
import org.slf4j.Logger; |
|
|
|
import org.slf4j.LoggerFactory; |
|
|
|
import org.slf4j.LoggerFactory; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Controller; |
|
|
|
import org.springframework.stereotype.Controller; |
|
|
|
import org.springframework.web.bind.annotation.RequestMapping; |
|
|
|
import org.springframework.web.bind.annotation.*; |
|
|
|
import org.springframework.web.bind.annotation.RequestMethod; |
|
|
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestParam; |
|
|
|
|
|
|
|
import org.springframework.web.bind.annotation.ResponseBody; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Controller |
|
|
|
@Controller |
|
|
|
@RequestMapping(value = "/test") |
|
|
|
@RequestMapping(value = "/websocket") |
|
|
|
@Api(value = "订单接口") |
|
|
|
@Api(value = "订单推送") |
|
|
|
public class HighMegController { |
|
|
|
public class HighMegController { |
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
@Autowired |
|
|
@ -24,16 +26,21 @@ public class HighMegController { |
|
|
|
|
|
|
|
|
|
|
|
private static Logger log = LoggerFactory.getLogger(HighMegController.class); |
|
|
|
private static Logger log = LoggerFactory.getLogger(HighMegController.class); |
|
|
|
|
|
|
|
|
|
|
|
@RequestMapping(value = "/websocket", method = RequestMethod.GET) |
|
|
|
@RequestMapping(value = "/websocket", method = RequestMethod.POST) |
|
|
|
@ResponseBody |
|
|
|
@ResponseBody |
|
|
|
@ApiOperation(value = "websocket") |
|
|
|
@ApiOperation(value = "websocket") |
|
|
|
public ResponseData websocket( |
|
|
|
public ResponseData websocket(@RequestBody JSONObject object) { |
|
|
|
@RequestParam(name = "userId", required = true) String userId, |
|
|
|
|
|
|
|
@RequestParam(name = "message", required = true) String message |
|
|
|
|
|
|
|
) { |
|
|
|
|
|
|
|
try { |
|
|
|
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("成功"); |
|
|
|
return ResponseMsgUtil.success("成功"); |
|
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
} catch (Exception e) { |
|
|
|