From 5f253695c4dfbfbf850c086802cdd6c43b71bb8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E5=BF=A0=E6=9E=97?= <170083662@qq.com> Date: Sun, 26 Apr 2026 14:17:44 +0800 Subject: [PATCH] =?UTF-8?q?fix(system):=20=E4=BF=AE=E5=A4=8D=E5=88=9B?= =?UTF-8?q?=E5=BB=BA=E8=B6=85=E7=BA=A7=E7=AE=A1=E7=90=86=E5=91=98=E6=97=B6?= =?UTF-8?q?=E6=9B=B4=E6=96=B0company=E5=92=8Ctenant=E7=9A=84userId?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在保存超级管理员用户后,更新company的userId字段 - 查询对应tenant并同步更新其userId字段 - 确保company和tenant的userId保持一致性 - 防止因userId未更新导致的数据不一致问题 --- .../system/service/impl/TenantServiceImpl.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/main/java/com/gxwebsoft/common/system/service/impl/TenantServiceImpl.java b/src/main/java/com/gxwebsoft/common/system/service/impl/TenantServiceImpl.java index ba23291..34c5733 100644 --- a/src/main/java/com/gxwebsoft/common/system/service/impl/TenantServiceImpl.java +++ b/src/main/java/com/gxwebsoft/common/system/service/impl/TenantServiceImpl.java @@ -152,6 +152,18 @@ public class TenantServiceImpl extends ServiceImpl impleme boolean result = userService.save(superAdmin); Integer superAdminUserId = superAdmin.getUserId(); + // 更新 company 和 tenant 的 userId + if (superAdminUserId != null && superAdminUserId > 0) { + company.setUserId(superAdminUserId); + companyService.updateById(company); + // 同时更新 tenant 的 userId + Tenant tenant = baseMapper.selectById(company.getTid()); + if (tenant != null) { + tenant.setUserId(superAdminUserId); + baseMapper.updateById(tenant); + } + } + // 创建角色 if (result) { Role role = new Role();