|
|
@@ -2,6 +2,8 @@ package com.ningdatech.pmapi.irs.manage; |
|
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil; |
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
import com.alibaba.fastjson.JSONArray; |
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
import com.ningdatech.basic.function.VUtils; |
|
|
|
import com.ningdatech.pmapi.common.enumeration.CommonEnum; |
|
|
@@ -83,8 +85,11 @@ public class AppIrsManage { |
|
|
|
|
|
|
|
ApiApplyDTO apiApply = new ApiApplyDTO(); |
|
|
|
apiApply.setAppId(appCode); |
|
|
|
ApiApplySearchResult apiApplySearchResult = this.searchApp(apiApply); |
|
|
|
|
|
|
|
JSONObject jsonObject = this.searchApp(apiApply); |
|
|
|
VUtils.isTrue(Objects.isNull(jsonObject)).throwMessage("应用在IRS不存在!"); |
|
|
|
JSONArray data = jsonObject.getJSONArray("data"); |
|
|
|
VUtils.isTrue(CollUtil.isNotEmpty(data)).throwMessage("应用在IRS不存在!"); |
|
|
|
ApiApplySearchResult apiApplySearchResult = JSON.parseObject(JSON.toJSONString(data.get(0)),ApiApplySearchResult.class); |
|
|
|
VUtils.isTrue(Objects.isNull(apiApplySearchResult)).throwMessage("应用在IRS不存在!"); |
|
|
|
|
|
|
|
long timestamp = System.currentTimeMillis(); |
|
|
@@ -149,7 +154,7 @@ public class AppIrsManage { |
|
|
|
* @return |
|
|
|
* @throws NoSuchAlgorithmException |
|
|
|
*/ |
|
|
|
public ApiApplySearchResult searchApp(ApiApplyDTO apply) throws NoSuchAlgorithmException { |
|
|
|
public JSONObject searchApp(ApiApplyDTO apply) throws NoSuchAlgorithmException { |
|
|
|
long timestamp = System.currentTimeMillis(); |
|
|
|
String appCode = apply.getAppId(); |
|
|
|
String requestSecret = RefreshKeyUtil.getRequestSecret(searchAppKey, searchAppScret); |
|
|
@@ -160,18 +165,33 @@ public class AppIrsManage { |
|
|
|
"&areaCode=&deptCode=&name="; |
|
|
|
log.info("url : {}",url); |
|
|
|
RestTemplate restTemplate = new RestTemplate(); |
|
|
|
ResponseEntity<ApiDTO> forEntity = restTemplate.getForEntity(url, ApiDTO.class); |
|
|
|
ResponseEntity<String> forEntity = restTemplate.getForEntity(url, String.class); |
|
|
|
|
|
|
|
log.info("查询应用目录 : {}",JSON.toJSONString(forEntity)); |
|
|
|
|
|
|
|
if(Objects.nonNull(forEntity.getBody()) && Objects.nonNull(forEntity.getBody().getDatas()) |
|
|
|
&& CollUtil.isNotEmpty(forEntity.getBody().getDatas().getApiApplySearchResult())){ |
|
|
|
return forEntity.getBody().getDatas().getApiApplySearchResult().get(0); |
|
|
|
if(Objects.nonNull(forEntity.getBody()) && Objects.nonNull(forEntity.getBody())){ |
|
|
|
JSONObject body = JSON.parseObject(forEntity.getBody()); |
|
|
|
if(Objects.isNull(body)){ |
|
|
|
return null; |
|
|
|
} |
|
|
|
JSONObject datas = body.getJSONObject("datas"); |
|
|
|
if(Objects.isNull(datas)){ |
|
|
|
return null; |
|
|
|
} |
|
|
|
JSONObject data = datas.getJSONObject("data"); |
|
|
|
if(Objects.isNull(data)){ |
|
|
|
return null; |
|
|
|
} |
|
|
|
JSONArray apiApplySearchResult = data.getJSONArray("apiApplySearchResult"); |
|
|
|
if(CollUtil.isEmpty(apiApplySearchResult)){ |
|
|
|
return null; |
|
|
|
} |
|
|
|
return apiApplySearchResult.getJSONObject(0); |
|
|
|
} |
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
public List<ApiApplySearchResult> searchApps(ApiApplyDTO apply) throws NoSuchAlgorithmException { |
|
|
|
public JSONArray searchApps(ApiApplyDTO apply) throws NoSuchAlgorithmException { |
|
|
|
long timestamp = System.currentTimeMillis(); |
|
|
|
String areaCode = StringUtils.isNotBlank(apply.getAreaCode()) ? |
|
|
|
apply.getAreaCode() : null; |
|
|
@@ -182,14 +202,26 @@ public class AppIrsManage { |
|
|
|
"pageNum=1&areaCode=" + areaCode + |
|
|
|
"&deptCode=&name="; |
|
|
|
RestTemplate restTemplate = new RestTemplate(); |
|
|
|
ResponseEntity<ApiDTO> forEntity = restTemplate.getForEntity(url, ApiDTO.class); |
|
|
|
ResponseEntity<String> forEntity = restTemplate.getForEntity(url, String.class); |
|
|
|
|
|
|
|
log.info("查询应用目录 : {}",JSON.toJSONString(forEntity)); |
|
|
|
|
|
|
|
if(Objects.nonNull(forEntity.getBody()) && Objects.nonNull(forEntity.getBody().getDatas()) |
|
|
|
&& CollUtil.isNotEmpty(forEntity.getBody().getDatas().getApiApplySearchResult())){ |
|
|
|
return forEntity.getBody().getDatas().getApiApplySearchResult(); |
|
|
|
if(Objects.nonNull(forEntity.getBody())){ |
|
|
|
JSONObject body = JSON.parseObject(forEntity.getBody()); |
|
|
|
if(Objects.isNull(body)){ |
|
|
|
return null; |
|
|
|
} |
|
|
|
JSONObject datas = body.getJSONObject("datas"); |
|
|
|
if(Objects.isNull(datas)){ |
|
|
|
return null; |
|
|
|
} |
|
|
|
JSONObject data = datas.getJSONObject("data"); |
|
|
|
if(Objects.isNull(data)){ |
|
|
|
return null; |
|
|
|
} |
|
|
|
JSONArray apiApplySearchResult = data.getJSONArray("apiApplySearchResult"); |
|
|
|
return apiApplySearchResult; |
|
|
|
} |
|
|
|
return Collections.emptyList(); |
|
|
|
return null; |
|
|
|
} |
|
|
|
} |