|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
import java.util.ArrayList; |
|
|
import java.util.List; |
|
|
import java.util.List; |
|
|
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* @author chenjiandong |
|
|
* @author chenjiandong |
|
|
|
|
|
|
|
|
List<BusinessSystemVo> businessSystemVoList = new ArrayList<>(); |
|
|
List<BusinessSystemVo> businessSystemVoList = new ArrayList<>(); |
|
|
for (AuthoritiesPo authoritiesPo : poList) { |
|
|
for (AuthoritiesPo authoritiesPo : poList) { |
|
|
BusinessSystemVo businessSystemVo = new BusinessSystemVo(); |
|
|
BusinessSystemVo businessSystemVo = new BusinessSystemVo(); |
|
|
Oauth2RegisteredClient oauth2RegisteredClient = oauth2RegisteredClientMapper.selectOne(Wrappers.<Oauth2RegisteredClient>lambdaQuery() |
|
|
|
|
|
.eq(Oauth2RegisteredClient::getClientId, authoritiesPo.getAuthority())); |
|
|
|
|
|
businessSystemVo.setClientId(authoritiesPo.getAuthority()); |
|
|
|
|
|
businessSystemVo.setName(oauth2RegisteredClient.getClientName()); |
|
|
|
|
|
businessSystemVoList.add(businessSystemVo); |
|
|
|
|
|
|
|
|
//TODO 后期维护各个业务平台 |
|
|
|
|
|
if ( authoritiesPo.getAuthority().contains("hhz")){ |
|
|
|
|
|
businessSystemVo.setClientId(HhzUrlConstant.HHZ_CLIENT); |
|
|
|
|
|
businessSystemVo.setName(HhzUrlConstant.HHZ_NAME); |
|
|
|
|
|
businessSystemVoList.add(businessSystemVo); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
businessSystemVoList=businessSystemVoList.stream().distinct().collect(Collectors.toList()); |
|
|
vo.setList(businessSystemVoList); |
|
|
vo.setList(businessSystemVoList); |
|
|
return vo; |
|
|
return vo; |
|
|
}); |
|
|
}); |
|
|
return JsonResult.success(pageData); |
|
|
return JsonResult.success(pageData); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 删除租户(逻辑删除) |
|
|
|
|
|
* |
|
|
|
|
|
* @return |
|
|
|
|
|
*/ |
|
|
|
|
|
@Override |
|
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
|
|
public JsonResult deleteTenant(OidcTenantDto dto, LoginUser loginUser) { |
|
|
|
|
|
TenantPo tenantPo = tenantMapper.selectById(dto.getId()); |
|
|
|
|
|
tenantPo.setEnabled(0); |
|
|
|
|
|
tenantMapper.updateById(tenantPo); |
|
|
|
|
|
UserPo userPo = clientUserMapper.selectByUserId(tenantPo.getUserId()); |
|
|
|
|
|
userPo.setEnabled(0); |
|
|
|
|
|
clientUserMapper.updatePass(userPo); |
|
|
|
|
|
if (dto.getClientId().contains(",")) { |
|
|
|
|
|
String[] codes = dto.getClientId().split(","); |
|
|
|
|
|
for (String code : codes) { |
|
|
|
|
|
return deleteResult(dto, code, loginUser); |
|
|
|
|
|
} |
|
|
|
|
|
} else { |
|
|
|
|
|
return deleteResult(dto, dto.getClientId(), loginUser); |
|
|
|
|
|
} |
|
|
|
|
|
return JsonResult.success(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 更新业务平台租户的相关基本信息 |
|
|
* 更新业务平台租户的相关基本信息 |
|
|
* |
|
|
* |
|
|
|
|
|
|
|
|
//设置地址(hhz平台) |
|
|
//设置地址(hhz平台) |
|
|
String url = platform.getPlatformUrl(); |
|
|
String url = platform.getPlatformUrl(); |
|
|
//根据不同业务平台进行动态匹配 |
|
|
//根据不同业务平台进行动态匹配 |
|
|
|
|
|
//TODO 后期维护各个业务平台 |
|
|
if (url.contains("hhz")) { |
|
|
if (url.contains("hhz")) { |
|
|
url = url + HhzUrlConstant.CREATE_TENANT; |
|
|
url = url + HhzUrlConstant.CREATE_TENANT; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
return JsonResult.success(); |
|
|
return JsonResult.success(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 删除请求 |
|
|
|
|
|
* |
|
|
|
|
|
* @param dto |
|
|
|
|
|
* @param code |
|
|
|
|
|
* @param loginUser |
|
|
|
|
|
* @return |
|
|
|
|
|
*/ |
|
|
|
|
|
private JsonResult deleteResult(OidcTenantDto 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(); |
|
|
|
|
|
//根据不同业务平台进行动态匹配 |
|
|
|
|
|
if (url.contains("hhz")) { |
|
|
|
|
|
url = url + HhzUrlConstant.DELETE_TENANT; |
|
|
|
|
|
} |
|
|
|
|
|
//else if (url.contains("lc")) { |
|
|
|
|
|
// url = url + HhzUrlConstant.UPDATE_TENANT; |
|
|
|
|
|
//} else if (url.contains("gs")) { |
|
|
|
|
|
// url = url + HhzUrlConstant.UPDATE_TENANT; |
|
|
|
|
|
//} |
|
|
|
|
|
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("业务平台删除租户响应失败" + response.getBody()); |
|
|
|
|
|
return JsonResult.error(response.getBody().getMsg()); |
|
|
|
|
|
} |
|
|
|
|
|
return JsonResult.success(); |
|
|
|
|
|
} |
|
|
} |
|
|
} |