Quellcode durchsuchen

更新

tags/v2.4.0
xiaoying vor 1 Jahr
Ursprung
Commit
2d413ebe03
1 geänderte Dateien mit 20 neuen und 7 gelöschten Zeilen
  1. +20
    -7
      tuoheng_oidc_admin/src/main/java/com/tuoheng/service/impl/ClientUserServiceImpl.java

+ 20
- 7
tuoheng_oidc_admin/src/main/java/com/tuoheng/service/impl/ClientUserServiceImpl.java Datei anzeigen

@@ -2,6 +2,7 @@ package com.tuoheng.service.impl;

import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.api.R;
import com.tuoheng.common.ServiceException;
import com.tuoheng.constant.HhzUrlConstant;
import com.tuoheng.mapper.*;
@@ -93,8 +94,8 @@ public class ClientUserServiceImpl implements ClientUserSevice {
if (createClientUserDto.getTenantFlag() == 1) {
TenantPo tenantPo = new TenantPo();
tenantPo.setUserId(userPo.getId());
//添加租户code
tenantPo .setCode(createClientUserDto.getCode());
//添加租户code
tenantPo.setCode(createClientUserDto.getCode());
tenantMapper.insertTenant(tenantPo);
}
}
@@ -225,9 +226,20 @@ public class ClientUserServiceImpl implements ClientUserSevice {
if (ObjectUtil.isNotNull(tTenant)) {
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()
.eq(Platform::getPlatformCode, dto.getClientId())
.eq(Platform::getPlatformCode, code)
.eq(Platform::getMark, 1));
if (ObjectUtil.isNull(platform)) {
return JsonResult.error("该业务平台不存在");
@@ -237,7 +249,11 @@ public class ClientUserServiceImpl implements ClientUserSevice {
resultRequestHeader.add("Authorization", "Bearer " + loginUser.getThToken());
HttpEntity httpEntity = new HttpEntity(dto, resultRequestHeader);
//设置地址(hhz平台)
String url = platform.getPlatformUrl() + HhzUrlConstant.CREATE_TENANT;
String url = platform.getPlatformUrl();
//根据不同业务平台进行动态匹配
if (url.contains("hhz")) {
url = url + HhzUrlConstant.CREATE_TENANT;
}
ResponseEntity<JsonResult> response;
try {
response = restTemplate.exchange(url, HttpMethod.POST, httpEntity, JsonResult.class);
@@ -252,9 +268,6 @@ public class ClientUserServiceImpl implements ClientUserSevice {
log.error("业务平台新增租户响应失败" + response.getBody());
return JsonResult.error(response.getBody().getMsg());
}

return JsonResult.success();
}


}

Laden…
Abbrechen
Speichern