|
@@ -1,6 +1,8 @@
|
|
|
package com.dragon.tj.portal.component.message;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
+import com.dragon.tj.portal.auth.model.LoginUser;
|
|
|
+import com.dragon.tj.portal.auth.service.TokenService;
|
|
|
import com.dragon.tj.portal.common.base.R;
|
|
|
import com.dragon.tj.portal.common.dto.message.MessageInfoReq;
|
|
|
import com.dragon.tj.portal.service.MessageInfoService;
|
|
@@ -11,6 +13,7 @@ import org.springframework.web.bind.annotation.*;
|
|
|
import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
import java.util.Map;
|
|
|
|
|
@@ -29,6 +32,9 @@ public class SseController {
|
|
|
@Autowired
|
|
|
private MessageInfoService messageInfoService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private TokenService tokenService;
|
|
|
+
|
|
|
@GetMapping("/subscribe/{clientId}")
|
|
|
public SseEmitter subscribe(@PathVariable String clientId, HttpServletResponse response) {
|
|
|
|
|
@@ -46,8 +52,10 @@ public class SseController {
|
|
|
}
|
|
|
|
|
|
@PostMapping("/publish")
|
|
|
- public R publish(@Validated @RequestBody MessageInfoReq messageInfoReq) {
|
|
|
+ public R publish(@Validated @RequestBody MessageInfoReq messageInfoReq, HttpServletRequest request) {
|
|
|
log.info("sseController req param is {}", JSON.toJSONString(messageInfoReq));
|
|
|
+ LoginUser loginUser = tokenService.getLoginUser(request);
|
|
|
+ log.info("sseController current people is {}", JSON.toJSONString(loginUser));
|
|
|
return messageInfoService.push(messageInfoReq);
|
|
|
}
|
|
|
|