|
|
@@ -9,9 +9,7 @@ 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.CommonConstant; |
|
|
|
import com.tuoheng.constant.HhzUrlConstant; |
|
|
|
import com.tuoheng.constant.*; |
|
|
|
import com.tuoheng.mapper.*; |
|
|
|
import com.tuoheng.model.dto.*; |
|
|
|
import com.tuoheng.model.param.*; |
|
|
@@ -239,10 +237,10 @@ public class ClientUserServiceImpl implements ClientUserSevice { |
|
|
|
return JsonResult.error("该租户账号已存在!"); |
|
|
|
} |
|
|
|
|
|
|
|
if (ObjectUtil.isEmpty(dto.getCode())) { |
|
|
|
if (ObjectUtil.isEmpty(dto.getTenantCode())) { |
|
|
|
return JsonResult.error("租户code不能为空"); |
|
|
|
} |
|
|
|
TTenant tTenant = tenantMapper.getByCode(dto.getCode()); |
|
|
|
TTenant tTenant = tenantMapper.getByCode(dto.getTenantCode()); |
|
|
|
if (ObjectUtil.isNotNull(tTenant)) { |
|
|
|
return JsonResult.error("该租户code已存在,请重新输入"); |
|
|
|
} |
|
|
@@ -253,15 +251,12 @@ public class ClientUserServiceImpl implements ClientUserSevice { |
|
|
|
if (result.getCode() != JsonResult.SUCCESS) { |
|
|
|
return result; |
|
|
|
} |
|
|
|
//TODO ->会导致循环终止(后期改进) |
|
|
|
return requestAirport(dto, loginUser, CommonConstant.ONE); |
|
|
|
} |
|
|
|
} else { |
|
|
|
JsonResult result = getResult(dto, dto.getClientId(), loginUser); |
|
|
|
if (result.getCode() != JsonResult.SUCCESS) { |
|
|
|
return result; |
|
|
|
} |
|
|
|
return requestAirport(dto, loginUser, CommonConstant.ONE); |
|
|
|
} |
|
|
|
return JsonResult.success(); |
|
|
|
} |
|
|
@@ -289,13 +284,31 @@ public class ClientUserServiceImpl implements ClientUserSevice { |
|
|
|
} |
|
|
|
List<BusinessSystemVo> businessSystemVoList = new ArrayList<>(); |
|
|
|
for (AuthoritiesPo authoritiesPo : poList) { |
|
|
|
BusinessSystemVo businessSystemVo = new BusinessSystemVo(); |
|
|
|
//TODO 后期维护各个业务平台 |
|
|
|
if (authoritiesPo.getAuthority().contains("hhz")) { |
|
|
|
BusinessSystemVo businessSystemVo = new BusinessSystemVo(); |
|
|
|
businessSystemVo.setClientId(HhzUrlConstant.HHZ_CLIENT); |
|
|
|
businessSystemVo.setName(HhzUrlConstant.HHZ_NAME); |
|
|
|
businessSystemVoList.add(businessSystemVo); |
|
|
|
} |
|
|
|
if (authoritiesPo.getAuthority().contains("airport")) { |
|
|
|
BusinessSystemVo businessSystemVo = new BusinessSystemVo(); |
|
|
|
businessSystemVo.setClientId(AirportConstant.AIRPORT_CLIENT); |
|
|
|
businessSystemVo.setName(AirportConstant.AIRPORT_NAME); |
|
|
|
businessSystemVoList.add(businessSystemVo); |
|
|
|
} |
|
|
|
if (authoritiesPo.getAuthority().contains("wateway")) { |
|
|
|
BusinessSystemVo businessSystemVo = new BusinessSystemVo(); |
|
|
|
businessSystemVo.setClientId(WateWayConstant.WATEWAY_CLIENT); |
|
|
|
businessSystemVo.setName(WateWayConstant.WATEWAY_NAME); |
|
|
|
businessSystemVoList.add(businessSystemVo); |
|
|
|
} |
|
|
|
if (authoritiesPo.getAuthority().contains("freeway")) { |
|
|
|
BusinessSystemVo businessSystemVo = new BusinessSystemVo(); |
|
|
|
businessSystemVo.setClientId(FreeWayConstant.FREEWAY_CLIENT); |
|
|
|
businessSystemVo.setName(FreeWayConstant.FREEWAY_NAME); |
|
|
|
businessSystemVoList.add(businessSystemVo); |
|
|
|
} |
|
|
|
} |
|
|
|
businessSystemVoList = businessSystemVoList.stream().distinct().collect(Collectors.toList()); |
|
|
|
vo.setList(businessSystemVoList); |
|
|
@@ -354,7 +367,7 @@ public class ClientUserServiceImpl implements ClientUserSevice { |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public JsonResult editTenant(OidcTenantDto dto, LoginUser loginUser) { |
|
|
|
|
|
|
|
if (ObjectUtil.isEmpty(dto.getCode())) { |
|
|
|
if (ObjectUtil.isEmpty(dto.getTenantCode())) { |
|
|
|
return JsonResult.error("租户code不能为空"); |
|
|
|
} |
|
|
|
if (dto.getClientId().contains(",")) { |
|
|
@@ -364,21 +377,18 @@ public class ClientUserServiceImpl implements ClientUserSevice { |
|
|
|
if (jsonResult.getCode() != JsonResult.SUCCESS) { |
|
|
|
return jsonResult; |
|
|
|
} |
|
|
|
//TODO ->会导致循环终止(后期改进) |
|
|
|
requestAirport(dto, loginUser, CommonConstant.TWO); |
|
|
|
} |
|
|
|
} else { |
|
|
|
JsonResult jsonResult = editResult(dto, dto.getClientId(), loginUser); |
|
|
|
if (jsonResult.getCode() != JsonResult.SUCCESS) { |
|
|
|
return jsonResult; |
|
|
|
} |
|
|
|
requestAirport(dto, loginUser, CommonConstant.TWO); |
|
|
|
} |
|
|
|
TTenant tTenant = tenantMapper.getByCode(dto.getCode()); |
|
|
|
TTenant tTenant = tenantMapper.getByCode(dto.getTenantCode()); |
|
|
|
dto.setId(tTenant.getId()); |
|
|
|
|
|
|
|
TenantPo tenantPo = new TenantPo(); |
|
|
|
tenantPo.setName(dto.getName()) |
|
|
|
tenantPo.setName(dto.getTenantName()) |
|
|
|
.setId(dto.getId()) |
|
|
|
.setCityCode(dto.getCityCode()) |
|
|
|
.setCityName(dto.getCityName()) |
|
|
@@ -419,11 +429,27 @@ public class ClientUserServiceImpl implements ClientUserSevice { |
|
|
|
HttpEntity httpEntity = new HttpEntity(dto, resultRequestHeader); |
|
|
|
//设置地址(hhz平台) |
|
|
|
String url = platform.getPlatformUrl(); |
|
|
|
|
|
|
|
//根据不同业务平台进行动态匹配 |
|
|
|
//TODO 后期维护各个业务平台 |
|
|
|
if (url.contains("hhz")) { |
|
|
|
url = url + HhzUrlConstant.CREATE_TENANT; |
|
|
|
switch (url){ |
|
|
|
//河湖长 |
|
|
|
case HhzUrlConstant.HHZ_CLIENT: |
|
|
|
url = url + HhzUrlConstant.CREATE_TENANT; |
|
|
|
break; |
|
|
|
//机场 |
|
|
|
case AirportConstant.AIRPORT_CLIENT: |
|
|
|
url = url + AirportConstant.CREATE_TENANT; |
|
|
|
break; |
|
|
|
//case AirportConstant.AIRPORT_CLIENT: |
|
|
|
// url = url + AirportConstant.CREATE_TENANT; |
|
|
|
// break; |
|
|
|
//case AirportConstant.AIRPORT_CLIENT: |
|
|
|
// url = url + AirportConstant.CREATE_TENANT; |
|
|
|
// break; |
|
|
|
default: |
|
|
|
break; |
|
|
|
} |
|
|
|
log.info("请求url:{}",url); |
|
|
|
ResponseEntity<JsonResult> response; |
|
|
|
try { |
|
|
|
response = restTemplate.exchange(url, HttpMethod.POST, httpEntity, JsonResult.class); |
|
|
@@ -463,14 +489,25 @@ public class ClientUserServiceImpl implements ClientUserSevice { |
|
|
|
//设置地址(hhz平台) |
|
|
|
String url = platform.getPlatformUrl(); |
|
|
|
//根据不同业务平台进行动态匹配 |
|
|
|
if (url.contains("hhz")) { |
|
|
|
url = url + HhzUrlConstant.UPDATE_TENANT; |
|
|
|
} |
|
|
|
//else if (url.contains("lc")) { |
|
|
|
// url = url + HhzUrlConstant.UPDATE_TENANT; |
|
|
|
//} else if (url.contains("gs")) { |
|
|
|
// url = url + HhzUrlConstant.UPDATE_TENANT; |
|
|
|
//} |
|
|
|
switch (url){ |
|
|
|
//河湖长 |
|
|
|
case HhzUrlConstant.HHZ_CLIENT: |
|
|
|
url = url + HhzUrlConstant.UPDATE_TENANT; |
|
|
|
break; |
|
|
|
//机场 |
|
|
|
case AirportConstant.AIRPORT_CLIENT: |
|
|
|
url = url + AirportConstant.EDIT_TENANT; |
|
|
|
break; |
|
|
|
//case AirportConstant.AIRPORT_CLIENT: |
|
|
|
// url = url + AirportConstant.CREATE_TENANT; |
|
|
|
// break; |
|
|
|
//case AirportConstant.AIRPORT_CLIENT: |
|
|
|
// url = url + AirportConstant.CREATE_TENANT; |
|
|
|
// break; |
|
|
|
default: |
|
|
|
break; |
|
|
|
} |
|
|
|
log.info("请求url:{}",url); |
|
|
|
ResponseEntity<JsonResult> response; |
|
|
|
try { |
|
|
|
response = restTemplate.exchange(url, HttpMethod.POST, httpEntity, JsonResult.class); |
|
|
@@ -510,14 +547,25 @@ public class ClientUserServiceImpl implements ClientUserSevice { |
|
|
|
//设置地址(hhz平台) |
|
|
|
String url = platform.getPlatformUrl(); |
|
|
|
//根据不同业务平台进行动态匹配 |
|
|
|
if (url.contains("hhz")) { |
|
|
|
url = url + HhzUrlConstant.DELETE_TENANT; |
|
|
|
} |
|
|
|
//else if (url.contains("lc")) { |
|
|
|
// url = url + HhzUrlConstant.UPDATE_TENANT; |
|
|
|
//} else if (url.contains("gs")) { |
|
|
|
// url = url + HhzUrlConstant.UPDATE_TENANT; |
|
|
|
//} |
|
|
|
switch (url){ |
|
|
|
//河湖长 |
|
|
|
case HhzUrlConstant.HHZ_CLIENT: |
|
|
|
url = url + HhzUrlConstant.DELETE_TENANT; |
|
|
|
break; |
|
|
|
//机场 |
|
|
|
case AirportConstant.AIRPORT_CLIENT: |
|
|
|
url = url + AirportConstant.DELETE_TENANT; |
|
|
|
break; |
|
|
|
//case AirportConstant.AIRPORT_CLIENT: |
|
|
|
// url = url + AirportConstant.CREATE_TENANT; |
|
|
|
// break; |
|
|
|
//case AirportConstant.AIRPORT_CLIENT: |
|
|
|
// url = url + AirportConstant.CREATE_TENANT; |
|
|
|
// break; |
|
|
|
default: |
|
|
|
break; |
|
|
|
} |
|
|
|
log.info("请求url:{}",url); |
|
|
|
ResponseEntity<JsonResult> response; |
|
|
|
try { |
|
|
|
response = restTemplate.exchange(url, HttpMethod.POST, httpEntity, JsonResult.class); |
|
|
@@ -534,72 +582,4 @@ public class ClientUserServiceImpl implements ClientUserSevice { |
|
|
|
} |
|
|
|
return JsonResult.success(); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 向机场发送请求-创建租户 |
|
|
|
* |
|
|
|
* @param dto |
|
|
|
* @param loginUser |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
private JsonResult requestAirport(OidcTenantDto dto, LoginUser loginUser, Integer type) { |
|
|
|
|
|
|
|
//type 1 创建 2 修改 3 删除 |
|
|
|
|
|
|
|
//填充请求类 |
|
|
|
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 = ""; |
|
|
|
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 { |
|
|
|
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(), "机场业务发送请求失败"); |
|
|
|
} |
|
|
|
if (null == response || !response.hasBody()) { |
|
|
|
log.error("机场业务发送请求失败响应失败"); |
|
|
|
throw new ServiceException(HttpStatus.BAD_REQUEST.value(), "机场业务发送请求失败"); |
|
|
|
} |
|
|
|
if (response.getBody().getCode() != JsonResult.SUCCESS) { |
|
|
|
log.error("机场业务发送请求失败响应失败" + response.getBody()); |
|
|
|
throw new ServiceException(HttpStatus.BAD_REQUEST.value(), response.getBody().getMsg()); |
|
|
|
} |
|
|
|
return JsonResult.success(); |
|
|
|
|
|
|
|
} |
|
|
|
} |