From 202e39775d58f7ed44cc81ae1bc0f8bab9aa6c46 Mon Sep 17 00:00:00 2001 From: Joyen <179017819@qq.com> Date: Wed, 11 Dec 2024 14:11:25 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=88=9B=E5=BB=BA=E7=A7=9F=E6=88=B7?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E5=91=98=E6=97=B6=EF=BC=8C=E5=85=B3=E9=97=AD?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E6=9D=83=E9=99=90=E3=80=82=EF=BC=88=E5=88=9B?= =?UTF-8?q?=E5=BB=BA=E7=9A=84=E7=A7=9F=E6=88=B7=E7=AE=A1=E7=90=86=E5=91=98?= =?UTF-8?q?=E6=9C=AA=E5=88=86=E9=85=8D=E8=A7=92=E8=89=B2=E5=89=8D=EF=BC=8C?= =?UTF-8?q?=E9=80=A0=E6=88=90=E6=9F=90=E4=BA=9B=E6=9F=A5=E8=AF=A2=E6=8B=BC?= =?UTF-8?q?=E6=8E=A5=E4=BA=86=E5=BD=93=E5=89=8D=E8=B6=85=E7=BA=A7=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E5=91=98=E7=9A=84userId=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/tenant/TenantServiceImpl.java | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/tenant/TenantServiceImpl.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/tenant/TenantServiceImpl.java index b4bdf1036d..775c14f4fa 100755 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/tenant/TenantServiceImpl.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/tenant/TenantServiceImpl.java @@ -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.date.DateUtils; 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.core.context.TenantContextHolder; import cn.iocoder.yudao.framework.tenant.core.util.TenantUtils; @@ -107,14 +108,17 @@ public class TenantServiceImpl implements TenantService { // 创建租户 TenantDO tenant = BeanUtils.toBean(createReqVO, TenantDO.class); tenantMapper.insert(tenant); - // 创建租户的管理员 - TenantUtils.execute(tenant.getId(), () -> { - // 创建角色 - Long roleId = createRole(tenantPackage); - // 创建用户,并分配角色 - Long userId = createUser(roleId, createReqVO); - // 修改租户的管理员 - tenantMapper.updateById(new TenantDO().setId(tenant.getId()).setContactUserId(userId)); + // 关闭数据权限,避免因为没有数据权限,查询不到数据 + DataPermissionUtils.executeIgnore(() -> { + // 创建租户的管理员 + TenantUtils.execute(tenant.getId(), () -> { + // 创建角色 + Long roleId = createRole(tenantPackage); + // 创建用户,并分配角色 + Long userId = createUser(roleId, createReqVO); + // 修改租户的管理员 + tenantMapper.updateById(new TenantDO().setId(tenant.getId()).setContactUserId(userId)); + }); }); return tenant.getId(); } -- Gitee