Browse Source

Merge branch 'develop' of gitadmin/tuoheng_oidc into release

tags/v2.4.0
xuziqing 1 year ago
parent
commit
57b1a67ccc
6 changed files with 132 additions and 3 deletions
  1. +27
    -0
      tuoheng_oidc_admin/src/main/java/com/tuoheng/common/CommonConfig.java
  2. +16
    -0
      tuoheng_oidc_admin/src/main/java/com/tuoheng/constant/AirportConstant.java
  3. +29
    -0
      tuoheng_oidc_admin/src/main/java/com/tuoheng/model/request/AirportRequest.java
  4. +51
    -2
      tuoheng_oidc_admin/src/main/java/com/tuoheng/service/impl/ClientUserServiceImpl.java
  5. +5
    -1
      tuoheng_oidc_admin/src/main/resources/application-dev.yml
  6. +4
    -0
      tuoheng_oidc_admin/src/main/resources/application-test.yml

+ 27
- 0
tuoheng_oidc_admin/src/main/java/com/tuoheng/common/CommonConfig.java View File

@@ -0,0 +1,27 @@
package com.tuoheng.common;

import lombok.Data;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;

/**
* @Author xiaoying
* @Date 2023/1/31 17:39
*/
@Configuration
@Data
public class CommonConfig {
/**
* 机场地址
*/
public static String airportURL;

/**
* 机场url
* @param url
*/
@Value("${tuoheng.airport-url}")
public void airportURL(String url) {
airportURL = url;
}
}

+ 16
- 0
tuoheng_oidc_admin/src/main/java/com/tuoheng/constant/AirportConstant.java View File

@@ -0,0 +1,16 @@
package com.tuoheng.constant;

import lombok.Data;

/**
*机场平台接口常量类
* @Author xiaoying
* @Date 2023/1/31 17:45
*/
public class AirportConstant {

/**
* 创建租户
*/
public static String CREATE_TENANT = "/api/airportInterface/addTenant";
}

+ 29
- 0
tuoheng_oidc_admin/src/main/java/com/tuoheng/model/request/AirportRequest.java View File

@@ -0,0 +1,29 @@
package com.tuoheng.model.request;

import lombok.Data;

/**
* 机场创建租户请求类
* @Author xiaoying
* @Date 2023/1/31 17:43
*/
@Data
public class AirportRequest {

/**
* 用户名
*/
private String username;
/**
* 租户名称
*/
private String tenantName;
/**
* 密码
*/
private String password;
/**
* 租户code
*/
private String tenantCode;
}

+ 51
- 2
tuoheng_oidc_admin/src/main/java/com/tuoheng/service/impl/ClientUserServiceImpl.java View File

@@ -7,7 +7,9 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.tuoheng.common.CommonConfig;
import com.tuoheng.common.ServiceException;
import com.tuoheng.constant.AirportConstant;
import com.tuoheng.constant.HhzUrlConstant;
import com.tuoheng.mapper.*;
import com.tuoheng.model.dto.*;
@@ -17,6 +19,7 @@ import com.tuoheng.model.po.ClientUserRolePo;
import com.tuoheng.model.po.TenantPo;
import com.tuoheng.model.po.UserPo;
import com.tuoheng.model.query.TenantQuery;
import com.tuoheng.model.request.AirportRequest;
import com.tuoheng.model.vo.BusinessSystemVo;
import com.tuoheng.model.vo.TenantVo;
import com.tuoheng.service.ClientUserSevice;
@@ -238,10 +241,18 @@ public class ClientUserServiceImpl implements ClientUserSevice {
if (dto.getClientId().contains(",")) {
String[] codes = dto.getClientId().split(",");
for (String code : codes) {
return getResult(dto, code, loginUser);
JsonResult result = getResult(dto, code, loginUser);
if (!"操作成功".equals(result.getMsg())) {
return result;
}
return requestAirport(dto, loginUser);
}
} else {
return getResult(dto, dto.getClientId(), loginUser);
JsonResult result = getResult(dto, dto.getClientId(), loginUser);
if (!"操作成功".equals(result.getMsg())) {
return result;
}
return requestAirport(dto, loginUser);
}
return JsonResult.success();
}
@@ -496,4 +507,42 @@ public class ClientUserServiceImpl implements ClientUserSevice {
}
return JsonResult.success();
}

/**
* 向机场发送请求
* @param dto
* @param loginUser
* @return
*/
private JsonResult requestAirport(OidcTenantDto dto,LoginUser loginUser) {
//填充请求类
AirportRequest request = new AirportRequest();
request.setPassword(dto.getPassword());
request.setUsername(dto.getUsername());
request.setTenantName(dto.getName());
request.setTenantCode(dto.getCode());

//设置请求头
HttpHeaders resultRequestHeader = new HttpHeaders();
resultRequestHeader.add("Authorization", "Bearer " + loginUser.getThToken());
HttpEntity httpEntity = new HttpEntity(request, resultRequestHeader);
//设置地址(机场平台->配置文件)
String url = CommonConfig.airportURL+ AirportConstant.CREATE_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();

}
}

+ 5
- 1
tuoheng_oidc_admin/src/main/resources/application-dev.yml View File

@@ -65,4 +65,8 @@ spring:
max-active: 1000 # 连接池最大连接数(使用负值表示没有限制)
max-wait: -1 # 连接池最大阻塞等待时间(使用负值表示没有限制)
max-idle: 10 # 连接池中的最大空闲连接
min-idle: 1 # 连接池中的最小空闲连接
min-idle: 1 # 连接池中的最小空闲连接
# 自定义配置
tuoheng:
#airport配置地址
airport-url: https://airport-test.t-aaron.com

+ 4
- 0
tuoheng_oidc_admin/src/main/resources/application-test.yml View File

@@ -65,3 +65,7 @@ spring:
max-wait: -1 # 连接池最大阻塞等待时间(使用负值表示没有限制)
max-idle: 10 # 连接池中的最大空闲连接
min-idle: 1 # 连接池中的最小空闲连接
# 自定义配置
tuoheng:
#airport配置地址
airport-url: https://airport-test.t-aaron.com

Loading…
Cancel
Save