|
|
@@ -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(), "机场平台创建租户失败"); |
|
|
|
} |