Преглед на файлове

对接机场业务平台对应租户的删改操作

tags/v2.4.0
xiaoying преди 1 година
родител
ревизия
603d24b9b4
променени са 3 файла, в които са добавени 89 реда и са изтрити 10 реда
  1. +9
    -0
      tuoheng_oidc_admin/src/main/java/com/tuoheng/constant/AirportConstant.java
  2. +27
    -0
      tuoheng_oidc_admin/src/main/java/com/tuoheng/constant/CommonConstant.java
  3. +53
    -10
      tuoheng_oidc_admin/src/main/java/com/tuoheng/service/impl/ClientUserServiceImpl.java

+ 9
- 0
tuoheng_oidc_admin/src/main/java/com/tuoheng/constant/AirportConstant.java Целия файл

@@ -13,4 +13,13 @@ public class AirportConstant {
* 创建租户
*/
public static String CREATE_TENANT = "/api/airportInterface/addTenant";
/**
* 修改租户
*/
public static String EDIT_TENANT = "/api/airportInterface/editTenant";
/**
* 删除租户
*/
public static String DELETE_TENANT = "/api/airportInterface/delTenant";

}

+ 27
- 0
tuoheng_oidc_admin/src/main/java/com/tuoheng/constant/CommonConstant.java Целия файл

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

/**
* 通用常量类
*
* @Author xiaoying
* @Date 2023/2/2 14:08
*/
public final class CommonConstant {
/**
* 构造器私有化
*/
private CommonConstant() {
// 可抛出异常,防止通过反射实例化对象
}

/**
* 常用数值
*/
public static final Integer ONE = 1;
public static final Integer TWO = 2;
public static final Integer THREE = 3;
public static final Integer FOUR = 4;
public static final Integer FIVE = 5;


}

+ 53
- 10
tuoheng_oidc_admin/src/main/java/com/tuoheng/service/impl/ClientUserServiceImpl.java Целия файл

@@ -10,6 +10,7 @@ import com.github.pagehelper.PageInfo;
import com.tuoheng.common.CommonConfig;
import com.tuoheng.common.ServiceException;
import com.tuoheng.constant.AirportConstant;
import com.tuoheng.constant.CommonConstant;
import com.tuoheng.constant.HhzUrlConstant;
import com.tuoheng.mapper.*;
import com.tuoheng.model.dto.*;
@@ -245,15 +246,15 @@ public class ClientUserServiceImpl implements ClientUserSevice {
if (!"操作成功".equals(result.getMsg())) {
return result;
}
//TODO ->会导致循环终止
return requestAirport(dto, loginUser);
//TODO ->会导致循环终止(后期改进)
return requestAirport(dto, loginUser, CommonConstant.ONE);
}
} else {
JsonResult result = getResult(dto, dto.getClientId(), loginUser);
if (!"操作成功".equals(result.getMsg())) {
return result;
}
return requestAirport(dto, loginUser);
return requestAirport(dto, loginUser, CommonConstant.ONE);
}
return JsonResult.success();
}
@@ -318,10 +319,19 @@ public class ClientUserServiceImpl implements ClientUserSevice {
if (dto.getClientId().contains(",")) {
String[] codes = dto.getClientId().split(",");
for (String code : codes) {
return deleteResult(dto, code, loginUser);
JsonResult jsonResult = deleteResult(dto, code, loginUser);
if (!"操作成功".equals(jsonResult.getMsg())) {
return jsonResult;
}
//TODO ->会导致循环终止(后期改进)
return requestAirport(dto, loginUser, CommonConstant.THREE);
}
} else {
return deleteResult(dto, dto.getClientId(), loginUser);
JsonResult jsonResult = deleteResult(dto, dto.getClientId(), loginUser);
if (!"操作成功".equals(jsonResult.getMsg())) {
return jsonResult;
}
return requestAirport(dto, loginUser, CommonConstant.THREE);
}
return JsonResult.success();
}
@@ -347,12 +357,15 @@ public class ClientUserServiceImpl implements ClientUserSevice {
if (!"操作成功".equals(jsonResult.getMsg())) {
return jsonResult;
}
//TODO ->会导致循环终止(后期改进)
return requestAirport(dto, loginUser, CommonConstant.TWO);
}
} else {
JsonResult jsonResult = editResult(dto, dto.getClientId(), loginUser);
if (!"操作成功".equals(jsonResult.getMsg())) {
return jsonResult;
}
return requestAirport(dto, loginUser, CommonConstant.TWO);
}
TTenant tTenant = tenantMapper.getByCode(dto.getCode());
dto.setId(tTenant.getId());
@@ -510,12 +523,16 @@ public class ClientUserServiceImpl implements ClientUserSevice {
}

/**
* 向机场发送请求
* 向机场发送请求-创建租户
*
* @param dto
* @param loginUser
* @return
*/
private JsonResult requestAirport(OidcTenantDto dto,LoginUser loginUser) {
private JsonResult requestAirport(OidcTenantDto dto, LoginUser loginUser, Integer type) {

//type 1 创建 2 修改 3 删除

//填充请求类
AirportRequest request = new AirportRequest();
request.setPassword(dto.getPassword());
@@ -528,10 +545,36 @@ public class ClientUserServiceImpl implements ClientUserSevice {
resultRequestHeader.add("Authorization", "Bearer " + loginUser.getThToken());
HttpEntity httpEntity = new HttpEntity(request, resultRequestHeader);
//设置地址(机场平台->配置文件)
String url = CommonConfig.airportURL+ AirportConstant.CREATE_TENANT;
ResponseEntity<JsonResult> response;
String url="";
switch (type) {
case 1:
url = CommonConfig.airportURL + AirportConstant.CREATE_TENANT;
break;
case 2:
url = CommonConfig.airportURL + AirportConstant.EDIT_TENANT;
break;
case 3:
url = CommonConfig.airportURL + AirportConstant.DELETE_TENANT+"/"+request.getTenantCode();
break;
default:
break;
}

ResponseEntity<JsonResult> response = null;
try {
response = restTemplate.exchange(url, HttpMethod.POST, httpEntity, JsonResult.class);
switch (type) {
case 1:
response = restTemplate.exchange(url, HttpMethod.POST, httpEntity, JsonResult.class);
break;
case 2:
response = restTemplate.exchange(url, HttpMethod.PUT, httpEntity, JsonResult.class);
break;
case 3:
response = restTemplate.exchange(url, HttpMethod.DELETE, httpEntity, JsonResult.class);
break;
default:
break;
}
} catch (Exception e) {
throw new ServiceException(HttpStatus.BAD_REQUEST.value(), "机场平台创建租户失败");
}

Loading…
Отказ
Запис