修正无法修改租户的问题

This commit is contained in:
dataprince 2024-02-01 21:03:12 +08:00
parent 5e8a8f6cd9
commit e0e190671f

View File

@ -301,21 +301,21 @@ public class SysTenantServiceImpl extends BaseServiceImpl<SysTenantMapper, SysTe
@Override
@Transactional(rollbackFor = Exception.class)
public boolean update(SysTenantBo sysTenantBo) {
SysTenant tenant = MapstructUtils.convert(sysTenantBo, SysTenant.class);
if (ObjectUtil.isNull(tenant)) {
throw new ServiceException("租户的参数为空!");
}
//如果更换了套餐则需要同步套餐sys_role_menu表
SysTenantVo oldTenantVo = selectById(tenant.getTenantId());
if (!oldTenantVo.getPackageId().equals(tenant.getPackageId())) {
boolean synced = syncTenantPackage(tenant.getTenantId(), tenant.getPackageId());
if (!synced) {
throw new ServiceException("同步套餐失败!");
}
}
return TenantHelper.ignore(() -> {
SysTenant tenant = MapstructUtils.convert(sysTenantBo, SysTenant.class);
if (ObjectUtil.isNull(tenant)) {
throw new ServiceException("租户的参数为空!");
}
//如果更换了套餐则需要同步套餐sys_role_menu表
SysTenantVo oldTenantVo = selectById(tenant.getTenantId());
if (!oldTenantVo.getPackageId().equals(tenant.getPackageId())) {
boolean synced = syncTenantPackage(tenant.getTenantId(), tenant.getPackageId());
if (!synced) {
throw new ServiceException("同步套餐失败!");
}
}
Long loginUserId = LoginHelper.getUserId();
Date createTime = new Date();
tenant.setUpdateBy(loginUserId);
@ -418,8 +418,8 @@ public class SysTenantServiceImpl extends BaseServiceImpl<SysTenantMapper, SysTe
public boolean syncTenantPackage(Long tenantId, Long packageId) {
return TenantHelper.ignore(() -> {
SysTenantPackage tenantPackage = tenantPackageMapper.selectOneById(packageId);
List<SysRole> roles = TenantHelper.ignore(() -> roleMapper.selectListByQuery(
QueryWrapper.create().from(SYS_ROLE).where(SYS_ROLE.TENANT_ID.eq(tenantId))));
List<SysRole> roles = roleMapper.selectListByQuery(
QueryWrapper.create().from(SYS_ROLE).where(SYS_ROLE.TENANT_ID.eq(tenantId)));
List<Long> roleIds = new ArrayList<>(roles.size() - 1);
List<Long> menuIds = StringUtils.splitTo(tenantPackage.getMenuIds(), Convert::toLong);
roles.forEach(role -> {