|
|
|
|
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.util.ObjectUtil; |
|
|
import cn.hutool.core.util.ObjectUtil; |
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
|
|
import com.baomidou.mybatisplus.extension.api.R; |
|
|
import com.tuoheng.common.ServiceException; |
|
|
import com.tuoheng.common.ServiceException; |
|
|
import com.tuoheng.constant.HhzUrlConstant; |
|
|
import com.tuoheng.constant.HhzUrlConstant; |
|
|
import com.tuoheng.mapper.*; |
|
|
import com.tuoheng.mapper.*; |
|
|
|
|
|
|
|
|
if (createClientUserDto.getTenantFlag() == 1) { |
|
|
if (createClientUserDto.getTenantFlag() == 1) { |
|
|
TenantPo tenantPo = new TenantPo(); |
|
|
TenantPo tenantPo = new TenantPo(); |
|
|
tenantPo.setUserId(userPo.getId()); |
|
|
tenantPo.setUserId(userPo.getId()); |
|
|
//添加租户code |
|
|
|
|
|
tenantPo .setCode(createClientUserDto.getCode()); |
|
|
|
|
|
|
|
|
//添加租户code |
|
|
|
|
|
tenantPo.setCode(createClientUserDto.getCode()); |
|
|
tenantMapper.insertTenant(tenantPo); |
|
|
tenantMapper.insertTenant(tenantPo); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (ObjectUtil.isNotNull(tTenant)) { |
|
|
if (ObjectUtil.isNotNull(tTenant)) { |
|
|
return JsonResult.error("该租户code已存在,请重新输入"); |
|
|
return JsonResult.error("该租户code已存在,请重新输入"); |
|
|
} |
|
|
} |
|
|
|
|
|
if (dto.getClientId().contains(",")) { |
|
|
|
|
|
String[] codes = dto.getClientId().split(","); |
|
|
|
|
|
for (String code : codes) { |
|
|
|
|
|
return getResult(dto, code, loginUser); |
|
|
|
|
|
} |
|
|
|
|
|
} else { |
|
|
|
|
|
return getResult(dto, dto.getClientId(), loginUser); |
|
|
|
|
|
} |
|
|
|
|
|
return JsonResult.success(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private JsonResult getResult(OidcTenantDto dto, String code, LoginUser loginUser) { |
|
|
Platform platform = platformMapper.selectOne(Wrappers.<Platform>lambdaQuery() |
|
|
Platform platform = platformMapper.selectOne(Wrappers.<Platform>lambdaQuery() |
|
|
.eq(Platform::getPlatformCode, dto.getClientId()) |
|
|
|
|
|
|
|
|
.eq(Platform::getPlatformCode, code) |
|
|
.eq(Platform::getMark, 1)); |
|
|
.eq(Platform::getMark, 1)); |
|
|
if (ObjectUtil.isNull(platform)) { |
|
|
if (ObjectUtil.isNull(platform)) { |
|
|
return JsonResult.error("该业务平台不存在"); |
|
|
return JsonResult.error("该业务平台不存在"); |
|
|
|
|
|
|
|
|
resultRequestHeader.add("Authorization", "Bearer " + loginUser.getThToken()); |
|
|
resultRequestHeader.add("Authorization", "Bearer " + loginUser.getThToken()); |
|
|
HttpEntity httpEntity = new HttpEntity(dto, resultRequestHeader); |
|
|
HttpEntity httpEntity = new HttpEntity(dto, resultRequestHeader); |
|
|
//设置地址(hhz平台) |
|
|
//设置地址(hhz平台) |
|
|
String url = platform.getPlatformUrl() + HhzUrlConstant.CREATE_TENANT; |
|
|
|
|
|
|
|
|
String url = platform.getPlatformUrl(); |
|
|
|
|
|
//根据不同业务平台进行动态匹配 |
|
|
|
|
|
if (url.contains("hhz")) { |
|
|
|
|
|
url = url + HhzUrlConstant.CREATE_TENANT; |
|
|
|
|
|
} |
|
|
ResponseEntity<JsonResult> response; |
|
|
ResponseEntity<JsonResult> response; |
|
|
try { |
|
|
try { |
|
|
response = restTemplate.exchange(url, HttpMethod.POST, httpEntity, JsonResult.class); |
|
|
response = restTemplate.exchange(url, HttpMethod.POST, httpEntity, JsonResult.class); |
|
|
|
|
|
|
|
|
log.error("业务平台新增租户响应失败" + response.getBody()); |
|
|
log.error("业务平台新增租户响应失败" + response.getBody()); |
|
|
return JsonResult.error(response.getBody().getMsg()); |
|
|
return JsonResult.error(response.getBody().getMsg()); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return JsonResult.success(); |
|
|
return JsonResult.success(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |