Compare commits

...

2 Commits

Author SHA1 Message Date
zrh050423 2249f74b9a Merge remote-tracking branch 'origin/backed-new' into backed-new 2024-12-22 15:02:49 +08:00
zrh050423 d520d06026 增加头部名称 2024-12-22 15:02:37 +08:00
5 changed files with 2046 additions and 4 deletions

2009
pom.xml

File diff suppressed because it is too large Load Diff

View File

@ -18,4 +18,5 @@ public class HealthSystemApplication {
SpringApplication.run(HealthSystemApplication.class, args);
}
}

View File

@ -26,7 +26,7 @@ public class JwtAuthenticationFilter extends OncePerRequestFilter {
// 仅对非登录和注册请求进行过滤
String uri = request.getRequestURI();
if (uri.contains("/login") || uri.contains("/register")) {
if (uri.contains("/login") || uri.contains("/register")||uri.contains("/socket.io")||uri.contains("/ws")) {
filterChain.doFilter(request, response);
return; // 如果是登录或注册接口直接通过不做 token 验证
}

View File

@ -0,0 +1,29 @@
package edu.zrh.healthsystem.config;
import com.corundumstudio.socketio.AckRequest;
import com.corundumstudio.socketio.SocketIOClient;
import com.corundumstudio.socketio.annotation.OnConnect;
import com.corundumstudio.socketio.annotation.OnDisconnect;
import com.corundumstudio.socketio.annotation.OnEvent;
import edu.zrh.healthsystem.model.Message;
import org.springframework.stereotype.Component;
@Component
public class MessageEventHandler {
@OnConnect
public void onConnect(SocketIOClient client) {
// 客户端连接时调用
}
@OnDisconnect
public void onDisconnect(SocketIOClient client) {
// 客户端断开连接时调用
}
@OnEvent(value = "send")
public void onSendMessage(SocketIOClient client, AckRequest request, Message message) {
// 接收到客户端发送的消息时调用
client.getNamespace().getBroadcastOperations().sendEvent("topic/message", message);
}
}

View File

@ -2,7 +2,10 @@ package edu.zrh.healthsystem.model;
import lombok.Data;
/**
* @author han
*/
public @Data class Message {
private String role="user";
private String content;
}
private String from;
private String text;
}