优化代码,顺便准备写历史聊天记录查询
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
package com.bao.dating.config;
|
||||
|
||||
|
||||
import com.bao.dating.handler.ChatWebSocketHandler;
|
||||
import com.bao.dating.controller.websocket.ChatWebSocketHandler;
|
||||
import com.bao.dating.interceptor.WsAuthInterceptor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.bao.dating.controller;
|
||||
|
||||
/**
|
||||
* 聊天控制器
|
||||
* @author lenovo
|
||||
*/
|
||||
public class ChatController {
|
||||
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.bao.dating.handler;
|
||||
package com.bao.dating.controller.websocket;
|
||||
|
||||
import com.bao.dating.message.WsMessage;
|
||||
import com.bao.dating.pojo.dto.ChatRecordSendDTO;
|
||||
@@ -42,7 +42,6 @@ public class WsAuthInterceptor implements HandshakeInterceptor {
|
||||
|
||||
// 从URL参数中获取token
|
||||
String token = servletRequest.getParameter("token");
|
||||
log.info("从URL参数获取到的token: {}", token != null ? "存在" : "不存在");
|
||||
|
||||
if (StringUtils.isBlank(token)) {
|
||||
log.error("WebSocket握手失败:令牌丢失");
|
||||
@@ -66,7 +65,6 @@ public class WsAuthInterceptor implements HandshakeInterceptor {
|
||||
|
||||
// 验证token并获取用户ID
|
||||
String userIdStr = JwtUtil.getSubjectFromToken(token);
|
||||
log.info("从token解析出的用户ID: {}", userIdStr);
|
||||
|
||||
if (StringUtils.isBlank(userIdStr) || !userIdStr.matches("\\d+")) {
|
||||
log.error("无效的用户ID格式: {}", userIdStr);
|
||||
|
||||
Reference in New Issue
Block a user