From e794ffa03dcba27b14323eb48e21c23fbfe88f66 Mon Sep 17 00:00:00 2001 From: "Ray.Hao" <1490493387@qq.com> Date: Wed, 25 Feb 2026 09:12:18 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E7=A7=BB=E9=99=A4WebSocket?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E5=B9=B6=E4=BC=98=E5=8C=96=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E5=AF=BC=E5=85=A5=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 移除WebSocket相关菜单和代码,优化用户导入时部门和角色的匹配逻辑,支持通过编码或名称匹配 --- sql/mysql/youlai_admin.sql | 11 ++-- .../controller/WebsocketController.java | 65 ------------------- .../platform/websocket/dto/TextMessage.java | 15 ----- .../service/impl/WebSocketServiceImpl.java | 8 ++- .../websocket/topic/WebSocketTopics.java | 1 - .../system/listener/UserImportListener.java | 20 +++--- 6 files changed, 23 insertions(+), 97 deletions(-) delete mode 100644 src/main/java/com/youlai/boot/platform/websocket/controller/WebsocketController.java delete mode 100644 src/main/java/com/youlai/boot/platform/websocket/dto/TextMessage.java diff --git a/sql/mysql/youlai_admin.sql b/sql/mysql/youlai_admin.sql index c93b0967..373aa23d 100644 --- a/sql/mysql/youlai_admin.sql +++ b/sql/mysql/youlai_admin.sql @@ -228,11 +228,10 @@ INSERT INTO `sys_menu` VALUES (708, 6, '0,6', '滚动文本', 'M', 'TextScroll', INSERT INTO `sys_menu` VALUES (709, 6, '0,6', '自适应表格操作列', 'M', 'AutoOperationColumn', 'operation-column', 'demo/auto-operation-column', NULL, NULL, 1, 1, 1, '', '', now(), now(), NULL); -- 功能演示 -INSERT INTO `sys_menu` VALUES (801, 7, '0,7', 'Websocket', 'M', 'WebSocket', '/function/websocket', 'demo/websocket', NULL, NULL, 1, 1, 1, '', '', now(), now(), NULL); -INSERT INTO `sys_menu` VALUES (802, 7, '0,7', 'Icons', 'M', 'IconDemo', 'icon-demo', 'demo/icons', NULL, NULL, 1, 1, 2, 'el-icon-Notification', '', now(), now(), NULL); -INSERT INTO `sys_menu` VALUES (803, 7, '0,7', '字典实时同步', 'M', 'DictSync', 'dict-sync', 'demo/dict-sync', NULL, NULL, NULL, 1, 3, '', '', now(), now(), NULL); -INSERT INTO `sys_menu` VALUES (804, 7, '0,7', 'VxeTable', 'M', 'VxeTable', 'vxe-table', 'demo/vxe-table/index', NULL, NULL, 1, 1, 4, 'el-icon-MagicStick', '', now(), now(), NULL); -INSERT INTO `sys_menu` VALUES (805, 7, '0,7', 'CURD单文件', 'M', 'CurdSingle', 'curd-single', 'demo/curd-single', NULL, NULL, 1, 1, 5, 'el-icon-Reading', '', now(), now(), NULL); +INSERT INTO `sys_menu` VALUES (801, 7, '0,7', 'Icons', 'M', 'IconDemo', 'icon-demo', 'demo/icons', NULL, NULL, 1, 1, 2, 'el-icon-Notification', '', now(), now(), NULL); +INSERT INTO `sys_menu` VALUES (802, 7, '0,7', '字典实时同步', 'M', 'DictSync', 'dict-sync', 'demo/dict-sync', NULL, NULL, NULL, 1, 3, '', '', now(), now(), NULL); +INSERT INTO `sys_menu` VALUES (803, 7, '0,7', 'VxeTable', 'M', 'VxeTable', 'vxe-table', 'demo/vxe-table/index', NULL, NULL, 1, 1, 4, 'el-icon-MagicStick', '', now(), now(), NULL); +INSERT INTO `sys_menu` VALUES (804, 7, '0,7', 'CURD单文件', 'M', 'CurdSingle', 'curd-single', 'demo/curd-single', NULL, NULL, 1, 1, 5, 'el-icon-Reading', '', now(), now(), NULL); -- 多级菜单示例 INSERT INTO `sys_menu` VALUES (910, 8, '0,8', '菜单一级', 'C', NULL, 'multi-level1', 'Layout', NULL, 1, NULL, 1, 1, '', '', now(), now(), NULL); @@ -341,7 +340,7 @@ INSERT INTO `sys_role_menu` VALUES (2, 601); -- 组件封装 INSERT INTO `sys_role_menu` VALUES (2, 701), (2, 702), (2, 703), (2, 704), (2, 705), (2, 706), (2, 707), (2, 708), (2, 709); -- 功能演示 / 多级菜单 -INSERT INTO `sys_role_menu` VALUES (2, 801), (2, 802), (2, 803), (2, 804), (2, 805), (2, 910), (2, 911), (2, 912), (2, 913); +INSERT INTO `sys_role_menu` VALUES (2, 801), (2, 802), (2, 803), (2, 804), (2, 910), (2, 911), (2, 912), (2, 913); -- 路由参数 INSERT INTO `sys_role_menu` VALUES (2, 1001), (2, 1002); diff --git a/src/main/java/com/youlai/boot/platform/websocket/controller/WebsocketController.java b/src/main/java/com/youlai/boot/platform/websocket/controller/WebsocketController.java deleted file mode 100644 index 2b737719..00000000 --- a/src/main/java/com/youlai/boot/platform/websocket/controller/WebsocketController.java +++ /dev/null @@ -1,65 +0,0 @@ -package com.youlai.boot.platform.websocket.controller; - -import com.youlai.boot.platform.websocket.dto.TextMessage; -import com.youlai.boot.platform.websocket.publisher.WebSocketPublisher; -import com.youlai.boot.platform.websocket.topic.WebSocketTopics; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.messaging.handler.annotation.DestinationVariable; -import org.springframework.messaging.handler.annotation.MessageMapping; -import org.springframework.messaging.handler.annotation.SendTo; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import java.security.Principal; - -/** - * WebSocket 测试用例控制层 - *
- * 包含点对点/广播发送消息 - * - * @author Ray.Hao - * @since 2.3.0 - */ -@RestController -@RequestMapping("/api/v1/websocket") -@RequiredArgsConstructor -@Slf4j -public class WebsocketController { - - private final WebSocketPublisher webSocketPublisher; - - - /** - * 广播发送消息 - * - * @param message 消息内容 - */ - @MessageMapping("/sendToAll") - @SendTo("/topic/notice") - public String sendToAll(String message) { - return "服务端通知: " + message; - } - - /** - * 点对点发送消息 - *
- * 模拟 张三 给 李四 发送消息场景
- *
- * @param principal 当前用户
- * @param username 接收消息的用户
- * @param message 消息内容
- */
- @MessageMapping("/sendToUser/{username}")
- public void sendToUser(Principal principal, @DestinationVariable String username, String message) {
- // 发送人
- String sender = principal.getName();
- // 接收人
- String receiver = username;
-
- log.info("发送人:{}; 接收人:{}", sender, receiver);
- // 发送消息给指定用户,拼接后路径 /user/{receiver}/queue/greeting
- webSocketPublisher.publishToUser(receiver, WebSocketTopics.USER_QUEUE_GREETING, new TextMessage(sender, message, System.currentTimeMillis()));
- }
-
-}
diff --git a/src/main/java/com/youlai/boot/platform/websocket/dto/TextMessage.java b/src/main/java/com/youlai/boot/platform/websocket/dto/TextMessage.java
deleted file mode 100644
index 53929687..00000000
--- a/src/main/java/com/youlai/boot/platform/websocket/dto/TextMessage.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package com.youlai.boot.platform.websocket.dto;
-
-import lombok.AllArgsConstructor;
-import lombok.Data;
-import lombok.NoArgsConstructor;
-
-@Data
-@AllArgsConstructor
-@NoArgsConstructor
-public class TextMessage {
-
- private String sender;
- private String content;
- private Long timestamp;
-}
diff --git a/src/main/java/com/youlai/boot/platform/websocket/service/impl/WebSocketServiceImpl.java b/src/main/java/com/youlai/boot/platform/websocket/service/impl/WebSocketServiceImpl.java
index 76bf5ce8..2ded5720 100644
--- a/src/main/java/com/youlai/boot/platform/websocket/service/impl/WebSocketServiceImpl.java
+++ b/src/main/java/com/youlai/boot/platform/websocket/service/impl/WebSocketServiceImpl.java
@@ -2,7 +2,6 @@ package com.youlai.boot.platform.websocket.service.impl;
import com.youlai.boot.platform.websocket.dto.DictChangeEvent;
import com.youlai.boot.platform.websocket.dto.OnlineUserDTO;
-import com.youlai.boot.platform.websocket.dto.TextMessage;
import com.youlai.boot.platform.websocket.publisher.WebSocketPublisher;
import com.youlai.boot.platform.websocket.session.UserSessionRegistry;
import com.youlai.boot.platform.websocket.service.WebSocketService;
@@ -11,6 +10,7 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.util.List;
+import java.util.Map;
/**
* WebSocket 服务实现类
@@ -215,7 +215,11 @@ public class WebSocketServiceImpl implements WebSocketService {
return;
}
- TextMessage systemMessage = new TextMessage("系统通知", message, System.currentTimeMillis());
+ Map