优化代码,顺便准备写历史聊天记录查询

This commit is contained in:
KilLze
2026-01-06 02:25:36 +08:00
parent fb2b7823b8
commit 2a9acb946e
4 changed files with 11 additions and 4 deletions

View File

@@ -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;

View File

@@ -0,0 +1,9 @@
package com.bao.dating.controller;
/**
* 聊天控制器
* @author lenovo
*/
public class ChatController {
}

View File

@@ -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;

View File

@@ -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);