Browse Source

Merge branch 'develop' of gitadmin/tuoheng_oidc into release

tags/v2.4.1
xuziqing 1 year ago
parent
commit
a9bfcb397b
1 changed files with 22 additions and 17 deletions
  1. +22
    -17
      tuoheng_oidc_admin/src/main/java/com/tuoheng/service/impl/TenantServiceImpl.java

+ 22
- 17
tuoheng_oidc_admin/src/main/java/com/tuoheng/service/impl/TenantServiceImpl.java View File

@@ -1,5 +1,6 @@
package com.tuoheng.service.impl;

import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUnit;
import cn.hutool.core.date.DateUtil;
@@ -583,15 +584,29 @@ public class TenantServiceImpl implements TenantService {
List<ClientRoleDto> deleteClientRoleDtoList;
List<ClientRoleDto> insertClientRoleDtoList;
deleteClientRoleDtoList = clientRoleDtoList.stream().filter(t -> !list.contains(t)).collect(Collectors.toList());
log.info("删除集合:{}",deleteClientRoleDtoList.toString());
log.info("删除集合:{}", deleteClientRoleDtoList.toString());
//新增
insertClientRoleDtoList = list.stream().filter(t -> !deleteList.contains(t)).collect(Collectors.toList());
log.info("新增集合:{}",deleteClientRoleDtoList.toString());
clientTenantDto.setClientRoleDtoList(deleteClientRoleDtoList);
//符合先删后增逻辑 则直接将原有租户已经对应的关联业务数据清除
JsonResult jsonResult = deleteTenant(clientTenantDto, loginUser);
if (jsonResult.getCode() != JsonResult.SUCCESS) {
return jsonResult;
log.info("新增集合:{}", insertClientRoleDtoList.toString());

if (CollectionUtil.isNotEmpty(deleteClientRoleDtoList)) {
clientTenantDto.setClientRoleDtoList(deleteClientRoleDtoList);
//符合先删后增逻辑 则直接将原有租户已经对应的关联业务数据清除
JsonResult jsonResult = deleteTenant(clientTenantDto, loginUser);
if (jsonResult.getCode() != JsonResult.SUCCESS) {
return jsonResult;
}
//原有集合
List<ClientRoleDto> finalClientRoleDtoList = getClientRoleDtos(deleteClientRoleDtoList);
//筛选出一样的则不做相关操作
//删除租户所有原始权限
for (ClientRoleDto clientRoleDto : finalClientRoleDtoList) {
clientUserRoleMapper.deleteByUserIdAndClient(tenant.getUserId(), clientRoleDto.getClientId());
authoritiesMapper.deleteByUserIdAndClient(tenant.getUserId(), clientRoleDto.getClientId());

}
log.info("租户原有关联各业务平台不同权限表删除完毕");

}
//更新租户创建成功后的返回实体类
CreateTenantVo vo = new CreateTenantVo();
@@ -603,16 +618,6 @@ public class TenantServiceImpl implements TenantService {
List<TenantEmploy> tenantEmploys = tenantEmployMapper.selectList(Wrappers.<TenantEmploy>lambdaQuery()
.eq(TenantEmploy::getTenantId, dto.getId()));
tenantEmploys.forEach(t -> tenantEmployMapper.deleteById(t));
//原有集合
List<ClientRoleDto> finalClientRoleDtoList = getClientRoleDtos(deleteClientRoleDtoList);
//筛选出一样的则不做相关操作
//删除租户所有原始权限
for (ClientRoleDto clientRoleDto : finalClientRoleDtoList) {
clientUserRoleMapper.deleteByUserIdAndClient(tenant.getUserId(), clientRoleDto.getClientId());
authoritiesMapper.deleteByUserIdAndClient(tenant.getUserId(), clientRoleDto.getClientId());

}
log.info("租户原有关联各业务平台不同权限表删除完毕");
//新增租户关联业务服务实例相关
StringBuilder PlatformName = new StringBuilder();
log.info(dto.getClientRoleDtoList().toString());

Loading…
Cancel
Save