Quellcode durchsuchen

Merge branch 'develop' of gitadmin/tuoheng_oidc into release

tags/v2.4.1
xuziqing vor 1 Jahr
Ursprung
Commit
0efa68fd4b
1 geänderte Dateien mit 73 neuen und 0 gelöschten Zeilen
  1. +73
    -0
      tuoheng_oidc_admin/src/main/java/com/tuoheng/service/impl/TenantServiceImpl.java

+ 73
- 0
tuoheng_oidc_admin/src/main/java/com/tuoheng/service/impl/TenantServiceImpl.java Datei anzeigen

@@ -591,8 +591,18 @@ public class TenantServiceImpl implements TenantService {
//现有对比 拿出不需要的数据进行删除
List<ClientRoleDto> deleteClientRoleDtoList;
List<ClientRoleDto> insertClientRoleDtoList;
List<ClientRoleDto> coincideClientRoleDtoList;
deleteClientRoleDtoList = clientRoleDtoList.stream().filter(t -> !list.contains(t)).collect(Collectors.toList());
coincideClientRoleDtoList = clientRoleDtoList.stream().filter(t -> list.contains(t)).collect(Collectors.toList());
log.info("删除集合:{}", deleteClientRoleDtoList.toString());
log.info("交集集合:{}", coincideClientRoleDtoList.toString());
//交集集合做更新操作
for (ClientRoleDto clientRoleDto : coincideClientRoleDtoList) {
JsonResult editResult = editResult(clientTenantDto, clientRoleDto.getClientId(), loginUser);
if (editResult.getCode() != JsonResult.SUCCESS) {
return editResult;
}
}
//新增
insertClientRoleDtoList = list.stream().filter(t -> !deleteList.contains(t)).collect(Collectors.toList());
log.info("新增集合:{}", insertClientRoleDtoList.toString());
@@ -832,4 +842,67 @@ public class TenantServiceImpl implements TenantService {
}
return JsonResult.success();
}


/**
* 更新请求
*
* @param dto
* @param code
* @param loginUser
* @return
*/
private JsonResult editResult(CreateClientTenantDto dto, String code, LoginUser loginUser) {
Platform platform = platformMapper.selectOne(Wrappers.<Platform>lambdaQuery()
.eq(Platform::getPlatformCode, code)
.eq(Platform::getMark, 1));
if (ObjectUtil.isNull(platform)) {
return JsonResult.error("该业务平台不存在");
}
//设置请求头
HttpHeaders resultRequestHeader = new HttpHeaders();
resultRequestHeader.add("Authorization", "Bearer " + loginUser.getThToken());
HttpEntity httpEntity = new HttpEntity(dto, resultRequestHeader);
//设置地址(hhz平台)
String url = platform.getPlatformUrl();
//根据不同业务平台进行动态匹配
switch (platform.getPlatformCode()) {
//河湖长
case HhzUrlConstant.HHZ_CLIENT:
url = url + HhzUrlConstant.UPDATE_TENANT;
break;
/* //机场
case AirportConstant.AIRPORT_CLIENT:
url = url + AirportConstant.DELETE_TENANT + CommonConstant.SLASH + dto.getTenantCode();
break;*/
case FreeWayConstant.FREEWAY_CLIENT:
url = url + FreeWayConstant.UPDATE_TENANT;
break;
case WaterWayConstant.WATERWAY_CLIENT:
url = url + WaterWayConstant.UPDATE_TENANT;
break;
//飞手
case PilotConstant.PILOT_CLIENT:
url = url + PilotConstant.UPDATE_TENANT;
break;
default:
break;
}
log.info("请求url:{}", url);
ResponseEntity<JsonResult> response;
try {
response = restTemplate.exchange(url, HttpMethod.POST, httpEntity, JsonResult.class);
} catch (Exception e) {
throw new ServiceException(HttpStatus.BAD_REQUEST.value(), "业务平台更新租户失败");
}
if (null == response || !response.hasBody()) {
log.error("业务平台更新租户响应失败");
throw new ServiceException(HttpStatus.BAD_REQUEST.value(), "业务平台更新租户失败");
}
if (response.getBody().getCode() != JsonResult.SUCCESS) {
log.error("业务平台更新租户响应失败,数据来源:" + platform.getPlatformName());
throw new ServiceException(HttpStatus.BAD_REQUEST.value(), response.getBody().getMsg());
}
return JsonResult.success();
}
}

Laden…
Abbrechen
Speichern