Browse Source

更新对应权限相关

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

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

vo.setPlatformName(PlatformName.substring(CommonConstant.ZERO, PlatformName.lastIndexOf(CommonConstant.SIGN))); vo.setPlatformName(PlatformName.substring(CommonConstant.ZERO, PlatformName.lastIndexOf(CommonConstant.SIGN)));
log.info("租户实例表添加完毕"); log.info("租户实例表添加完毕");
//1.开始判断租户对应需要的平台并进行匹对 //1.开始判断租户对应需要的平台并进行匹对
List<ClientRoleDto> clientRoleDtoList = getClientRoleDtos(createClientTenantDto);
List<ClientRoleDto> clientRoleDtoList = getClientRoleDtos(createClientTenantDto.getClientRoleDtoList());
List<AuthoritiesPo> authoritiesPos = new ArrayList<>(); List<AuthoritiesPo> authoritiesPos = new ArrayList<>();
List<ClientUserRolePo> clientUserRolePoArrayList = new ArrayList<>(); List<ClientUserRolePo> clientUserRolePoArrayList = new ArrayList<>();
//2.添加租户对应相关信息 //2.添加租户对应相关信息
/** /**
* 匹配对应业务系统对应的标识,并封装返回方便后续操作 * 匹配对应业务系统对应的标识,并封装返回方便后续操作
* *
* @param createClientTenantDto
* @param clientRoleDtoList
* @return * @return
*/ */
private List<ClientRoleDto> getClientRoleDtos(CreateClientTenantDto createClientTenantDto) {
List<ClientRoleDto> clientRoleDtoList = new ArrayList<>();
private List<ClientRoleDto> getClientRoleDtos(List<ClientRoleDto> clientRoleDtoList) {
List<ClientRoleDto> list = new ArrayList<>();
//遍历获取参数进项封装 //遍历获取参数进项封装
for (ClientRoleDto dto : createClientTenantDto.getClientRoleDtoList()) {
for (ClientRoleDto dto : clientRoleDtoList) {


switch (dto.getClientId()) { switch (dto.getClientId()) {
//暂时河湖长,动态匹配其他平台 //暂时河湖长,动态匹配其他平台
case HhzUrlConstant.HHZ_CLIENT: case HhzUrlConstant.HHZ_CLIENT:
addClientRoleDtoList(HhzUrlConstant.HHZ_CLIENT_MP, dto, clientRoleDtoList);
addClientRoleDtoList(HhzUrlConstant.HHZ_CLIENT_ADMIN, dto, clientRoleDtoList);
addClientRoleDtoList(HhzUrlConstant.HHZ_CLIENT_MP, dto, list);
addClientRoleDtoList(HhzUrlConstant.HHZ_CLIENT_ADMIN, dto, list);
break; break;
case PilotConstant.PILOT_CLIENT: case PilotConstant.PILOT_CLIENT:
addClientRoleDtoList(PilotConstant.PILOT_CLIENT_ADMIN, dto, clientRoleDtoList);
addClientRoleDtoList(PilotConstant.PILOT_CLIENT_MP, dto, clientRoleDtoList);
addClientRoleDtoList(PilotConstant.PILOT_CLIENT_ADMIN, dto, list);
addClientRoleDtoList(PilotConstant.PILOT_CLIENT_MP, dto, list);
break; break;
case FreeWayConstant.FREEWAY_CLIENT: case FreeWayConstant.FREEWAY_CLIENT:
addClientRoleDtoList(FreeWayConstant.FREEWAY_CLIENT_ADMIN, dto, clientRoleDtoList);
addClientRoleDtoList(FreeWayConstant.FREEWAY_CLIENT_MP, dto, clientRoleDtoList);
addClientRoleDtoList(FreeWayConstant.FREEWAY_CLIENT_ADMIN, dto, list);
addClientRoleDtoList(FreeWayConstant.FREEWAY_CLIENT_MP, dto, list);
break; break;
case WaterWayConstant.WATERWAY_CLIENT: case WaterWayConstant.WATERWAY_CLIENT:
addClientRoleDtoList(WaterWayConstant.WATERWAY_CLIENT_ADMIN, dto, clientRoleDtoList);
addClientRoleDtoList(WaterWayConstant.WATERWAY_CLIENT_MP, dto, clientRoleDtoList);
addClientRoleDtoList(WaterWayConstant.WATERWAY_CLIENT_ADMIN, dto, list);
addClientRoleDtoList(WaterWayConstant.WATERWAY_CLIENT_MP, dto, list);
break; break;
default: default:
break; break;
} }


} }
return clientRoleDtoList;
return list;
} }


/** /**
} }
log.info("业务系统新增租户成功"); log.info("业务系统新增租户成功");
//原有集合 //原有集合
List<ClientRoleDto> clientRoleDtos = getClientRoleDtos(dto.getClientRoleDtoList());
List<ClientRoleDto> finalClientRoleDtoList = clientRoleDtoList; List<ClientRoleDto> finalClientRoleDtoList = clientRoleDtoList;
list= list.stream().filter(t -> !finalClientRoleDtoList.contains(t)).collect(Collectors.toList());
clientRoleDtos= clientRoleDtos.stream().filter(t -> !finalClientRoleDtoList.contains(t)).collect(Collectors.toList());


List<AuthoritiesPo> authoritiesPos = new ArrayList<>(); List<AuthoritiesPo> authoritiesPos = new ArrayList<>();
List<ClientUserRolePo> clientUserRolePoArrayList = new ArrayList<>(); List<ClientUserRolePo> clientUserRolePoArrayList = new ArrayList<>();


for (ClientRoleDto clientRoleDto : list) {
for (ClientRoleDto clientRoleDto : clientRoleDtos) {
//添加角色权限相关 //添加角色权限相关
AuthoritiesPo authoritiesPo = new AuthoritiesPo() AuthoritiesPo authoritiesPo = new AuthoritiesPo()
.setUserId(tenant.getUserId()) .setUserId(tenant.getUserId())

Loading…
Cancel
Save