Sfoglia il codice sorgente

Merge branch 'develop' of gitadmin/tuoheng_oidc into release

tags/v2.4.1
xuziqing 1 anno fa
parent
commit
46835efad5
1 ha cambiato i file con 17 aggiunte e 9 eliminazioni
  1. +17
    -9
      tuoheng_oidc_admin/src/main/java/com/tuoheng/service/impl/TenantServiceImpl.java

+ 17
- 9
tuoheng_oidc_admin/src/main/java/com/tuoheng/service/impl/TenantServiceImpl.java Vedi File

if (ObjectUtil.isNull(tenant)) { if (ObjectUtil.isNull(tenant)) {
return JsonResult.error(ServiceExceptionEnum.GET_NO_DATA.getMessage()); return JsonResult.error(ServiceExceptionEnum.GET_NO_DATA.getMessage());
} }
//现有list
List<ClientRoleDto> list = dto.getClientRoleDtoList();
//现有集合
List<ClientRoleDto> clientRoleDtos = getClientRoleDtos(list);
//租户对应的业务平台相关信息 //租户对应的业务平台相关信息
//删除这个租户原本存在的所有业务平台下的信息 //删除这个租户原本存在的所有业务平台下的信息
List<ClientRoleDto> clientRoleDtoList = new ArrayList<>(); List<ClientRoleDto> clientRoleDtoList = new ArrayList<>();
clientRoleDto.setClientId(clientUserRolePo.getClientId().substring(CommonConstant.ZERO, clientUserRolePo.getClientId().lastIndexOf(CommonConstant.BARS))); clientRoleDto.setClientId(clientUserRolePo.getClientId().substring(CommonConstant.ZERO, clientUserRolePo.getClientId().lastIndexOf(CommonConstant.BARS)));
clientRoleDtoList.add(clientRoleDto); clientRoleDtoList.add(clientRoleDto);
} }
//原有集合
clientRoleDtoList = clientRoleDtoList.stream().distinct().collect(Collectors.toList()); clientRoleDtoList = clientRoleDtoList.stream().distinct().collect(Collectors.toList());
clientTenantDto.setClientRoleDtoList(clientRoleDtoList);
List<ClientRoleDto> deleteList = clientRoleDtoList;
//现有对比 拿出不需要的数据进行删除
List<ClientRoleDto> deleteClientRoleDtoList;
List<ClientRoleDto> insertClientRoleDtoList;
deleteClientRoleDtoList = list.stream().filter(t -> !deleteList.contains(t)).collect(Collectors.toList());
//新增
insertClientRoleDtoList = clientRoleDtoList.stream().filter(t -> !list.contains(t)).collect(Collectors.toList());
clientTenantDto.setClientRoleDtoList(deleteClientRoleDtoList);
//符合先删后增逻辑 则直接将原有租户已经对应的关联业务数据清除 //符合先删后增逻辑 则直接将原有租户已经对应的关联业务数据清除
JsonResult jsonResult = deleteTenant(clientTenantDto, loginUser); JsonResult jsonResult = deleteTenant(clientTenantDto, loginUser);
if (jsonResult.getCode() != JsonResult.SUCCESS) { if (jsonResult.getCode() != JsonResult.SUCCESS) {
List<TenantEmploy> tenantEmploys = tenantEmployMapper.selectList(Wrappers.<TenantEmploy>lambdaQuery() List<TenantEmploy> tenantEmploys = tenantEmployMapper.selectList(Wrappers.<TenantEmploy>lambdaQuery()
.eq(TenantEmploy::getTenantId, dto.getId())); .eq(TenantEmploy::getTenantId, dto.getId()));
tenantEmploys.forEach(t -> tenantEmployMapper.deleteById(t)); tenantEmploys.forEach(t -> tenantEmployMapper.deleteById(t));
//现有list
List<ClientRoleDto> list = dto.getClientRoleDtoList();
//现有集合
List<ClientRoleDto> clientRoleDtos = getClientRoleDtos(list);
//原有集合 //原有集合
List<ClientRoleDto> finalClientRoleDtoList = getClientRoleDtos(clientRoleDtoList);
List<ClientRoleDto> finalClientRoleDtoList = getClientRoleDtos(deleteClientRoleDtoList);
//筛选出一样的则不做相关操作 //筛选出一样的则不做相关操作
//删除租户所有原始权限 //删除租户所有原始权限
for (ClientRoleDto clientRoleDto : finalClientRoleDtoList) { for (ClientRoleDto clientRoleDto : finalClientRoleDtoList) {
vo.setEffectiveDate(DateUtil.formatDate(tenantItem.getBeginTime()) + CommonConstant.TILDE + DateUtil.formatDate(tenantItem.getEndTime())); vo.setEffectiveDate(DateUtil.formatDate(tenantItem.getBeginTime()) + CommonConstant.TILDE + DateUtil.formatDate(tenantItem.getEndTime()));
log.info("租户项目相关信息更新完毕"); log.info("租户项目相关信息更新完毕");
//todo:调用业务系统完成租户创建 //todo:调用业务系统完成租户创建
for (ClientRoleDto clientRoleDto : list) {
for (ClientRoleDto clientRoleDto : insertClientRoleDtoList) {
try { try {
log.info("参数:{}", clientRoleDto.toString()); log.info("参数:{}", clientRoleDto.toString());
JsonResult result = getResult(dto, clientRoleDto.getClientId(), loginUser); JsonResult result = getResult(dto, clientRoleDto.getClientId(), loginUser);
//创建新的租户对应权限相关数据 //创建新的租户对应权限相关数据
List<AuthoritiesPo> authoritiesPos = new ArrayList<>(); List<AuthoritiesPo> authoritiesPos = new ArrayList<>();
List<ClientUserRolePo> clientUserRolePoArrayList = new ArrayList<>(); List<ClientUserRolePo> clientUserRolePoArrayList = new ArrayList<>();
for (ClientRoleDto clientRoleDto : clientRoleDtos) {
insertClientRoleDtoList = getClientRoleDtos(insertClientRoleDtoList);
for (ClientRoleDto clientRoleDto : insertClientRoleDtoList) {
//添加角色权限相关 //添加角色权限相关
AuthoritiesPo authoritiesPo = new AuthoritiesPo() AuthoritiesPo authoritiesPo = new AuthoritiesPo()
.setUserId(tenant.getUserId()) .setUserId(tenant.getUserId())

Loading…
Annulla
Salva