fix(system): 修复创建超级管理员时更新company和tenant的userId
- 在保存超级管理员用户后,更新company的userId字段 - 查询对应tenant并同步更新其userId字段 - 确保company和tenant的userId保持一致性 - 防止因userId未更新导致的数据不一致问题
This commit is contained in:
@@ -152,6 +152,18 @@ public class TenantServiceImpl extends ServiceImpl<TenantMapper, Tenant> impleme
|
|||||||
boolean result = userService.save(superAdmin);
|
boolean result = userService.save(superAdmin);
|
||||||
Integer superAdminUserId = superAdmin.getUserId();
|
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) {
|
if (result) {
|
||||||
Role role = new Role();
|
Role role = new Role();
|
||||||
|
|||||||
Reference in New Issue
Block a user