From 21130253a401e54a5aeb3c6d5e1fd86baeb4f05b Mon Sep 17 00:00:00 2001 From: PIG AI Date: Tue, 1 Jul 2025 00:47:38 +0800 Subject: [PATCH] =?UTF-8?q?feat(tenant):=20=E9=87=8D=E6=9E=84=E7=A7=9F?= =?UTF-8?q?=E6=88=B7=E7=94=A8=E6=88=B7=E5=85=B3=E7=B3=BB=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新增sys_tenant_user表用于存储租户与用户的多对多关系 - 移除SysTenantServiceImpl中初始化用户的冗余逻辑 - 调整数据库初始化脚本以适配新的用户租户关系模型 --- .gitignore | 2 +- db/0pigxx_boot.sql | 17 +++++++++++++++++ db/2pigxx.sql | 16 ++++++++++++++++ .../service/impl/SysTenantServiceImpl.java | 12 ------------ 4 files changed, 34 insertions(+), 13 deletions(-) diff --git a/.gitignore b/.gitignore index b782b8c4d..988d5f855 100644 --- a/.gitignore +++ b/.gitignore @@ -64,4 +64,4 @@ application-preview.yml node_modules ### test -docker-compose-test.yml \ No newline at end of file +*-aitest* \ No newline at end of file diff --git a/db/0pigxx_boot.sql b/db/0pigxx_boot.sql index 52284f886..81c47f44f 100644 --- a/db/0pigxx_boot.sql +++ b/db/0pigxx_boot.sql @@ -1368,6 +1368,23 @@ BEGIN; INSERT INTO `sys_user_dept` (`user_id`, `dept_id`, `tenant_id`) VALUES (1, 1, 1); COMMIT; +-- ---------------------------- +-- Table structure for sys_tenant_user +-- ---------------------------- +DROP TABLE IF EXISTS `sys_tenant_user`; +CREATE TABLE `sys_tenant_user` ( + `tenant_id` bigint NOT NULL COMMENT '租户ID', + `user_id` bigint NOT NULL COMMENT '用户ID', + PRIMARY KEY (`tenant_id`,`user_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='租户用户表'; + +-- ---------------------------- +-- Records of sys_tenant_user +-- ---------------------------- +BEGIN; +INSERT INTO `sys_tenant_user` (`tenant_id`, `user_id`) VALUES (1, 1); +COMMIT; + -- ---------------------------- -- Table structure for sys_message -- ---------------------------- diff --git a/db/2pigxx.sql b/db/2pigxx.sql index 0a4baf1ba..43e261dd3 100644 --- a/db/2pigxx.sql +++ b/db/2pigxx.sql @@ -1418,4 +1418,20 @@ BEGIN; INSERT INTO `sys_user_dept` (`user_id`, `dept_id`, `tenant_id`) VALUES (1, 1, 1); COMMIT; +-- ---------------------------- +-- Table structure for sys_tenant_user +-- ---------------------------- +DROP TABLE IF EXISTS `sys_tenant_user`; +CREATE TABLE `sys_tenant_user` ( + `tenant_id` bigint NOT NULL COMMENT '租户ID', + `user_id` bigint NOT NULL COMMENT '用户ID', + PRIMARY KEY (`tenant_id`,`user_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='租户用户表'; + +-- ---------------------------- +-- Records of sys_tenant_user +-- ---------------------------- +BEGIN; +INSERT INTO `sys_tenant_user` (`tenant_id`, `user_id`) VALUES (1, 1); +COMMIT; SET FOREIGN_KEY_CHECKS = 1; diff --git a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/impl/SysTenantServiceImpl.java b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/impl/SysTenantServiceImpl.java index 6e0e1d057..1f6c987f4 100755 --- a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/impl/SysTenantServiceImpl.java +++ b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/impl/SysTenantServiceImpl.java @@ -51,7 +51,6 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.lang.reflect.Field; -import java.time.LocalDateTime; import java.util.*; /** @@ -159,12 +158,6 @@ public class SysTenantServiceImpl extends ServiceImpl