Pre Merge pull request !1154 from Joyen/bug-fix

This commit is contained in:
Joyen 2025-04-26 02:00:38 +00:00 committed by Gitee
commit acfae5b0a2
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
1 changed files with 12 additions and 8 deletions

View File

@ -9,6 +9,7 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
import cn.iocoder.yudao.framework.common.util.date.DateUtils; import cn.iocoder.yudao.framework.common.util.date.DateUtils;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils; import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.framework.datapermission.core.util.DataPermissionUtils;
import cn.iocoder.yudao.framework.tenant.config.TenantProperties; import cn.iocoder.yudao.framework.tenant.config.TenantProperties;
import cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder; import cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder;
import cn.iocoder.yudao.framework.tenant.core.util.TenantUtils; import cn.iocoder.yudao.framework.tenant.core.util.TenantUtils;
@ -107,6 +108,8 @@ public class TenantServiceImpl implements TenantService {
// 创建租户 // 创建租户
TenantDO tenant = BeanUtils.toBean(createReqVO, TenantDO.class); TenantDO tenant = BeanUtils.toBean(createReqVO, TenantDO.class);
tenantMapper.insert(tenant); tenantMapper.insert(tenant);
// 关闭数据权限避免因为没有数据权限查询不到数据
DataPermissionUtils.executeIgnore(() -> {
// 创建租户的管理员 // 创建租户的管理员
TenantUtils.execute(tenant.getId(), () -> { TenantUtils.execute(tenant.getId(), () -> {
// 创建角色 // 创建角色
@ -116,6 +119,7 @@ public class TenantServiceImpl implements TenantService {
// 修改租户的管理员 // 修改租户的管理员
tenantMapper.updateById(new TenantDO().setId(tenant.getId()).setContactUserId(userId)); tenantMapper.updateById(new TenantDO().setId(tenant.getId()).setContactUserId(userId));
}); });
});
return tenant.getId(); return tenant.getId();
} }