|
|
@@ -0,0 +1,86 @@ |
|
|
|
package com.ningdatech.pmapi.irs; |
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.ningdatech.irs.service.IRefreshTokenService; |
|
|
|
import com.ningdatech.pmapi.AppTests; |
|
|
|
import com.ningdatech.pmapi.common.util.CryptUtils; |
|
|
|
import com.ningdatech.pmapi.common.util.HttpUtil; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.junit.Test; |
|
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
|
import org.springframework.http.HttpMethod; |
|
|
|
import org.springframework.http.ResponseEntity; |
|
|
|
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory; |
|
|
|
import org.springframework.web.client.RestTemplate; |
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
|
import java.util.Objects; |
|
|
|
|
|
|
|
/** |
|
|
|
* @Classname CoreTest |
|
|
|
* @Description |
|
|
|
* @Date 2023/8/31 17:21 |
|
|
|
* @Author PoffyZhang |
|
|
|
*/ |
|
|
|
@Slf4j |
|
|
|
public class CoreTest extends AppTests { |
|
|
|
|
|
|
|
@Value("${irs.core-biz.appKey}") |
|
|
|
private String appKey; |
|
|
|
|
|
|
|
@Value("${irs.core-biz.appSecret}") |
|
|
|
private String appSecret; |
|
|
|
|
|
|
|
@Value("${irs.core-biz.url}") |
|
|
|
private String coreBizUrl; |
|
|
|
|
|
|
|
@Value("${irs.core-biz.interfaceName}") |
|
|
|
private String interfaceName; |
|
|
|
@Resource |
|
|
|
private IRefreshTokenService refreshTokenService; |
|
|
|
|
|
|
|
@Value("${irs.interface-refresh.request-token-url}") |
|
|
|
private String govRequestTokenUrl; |
|
|
|
@Value("${irs.interface-refresh.refresh-token-url}") |
|
|
|
private String govRefreshTokenUrl; |
|
|
|
|
|
|
|
@Test |
|
|
|
public void searchCoreBiz() { |
|
|
|
String businessName = ""; |
|
|
|
String orgCode = ""; |
|
|
|
Integer limit = 10; |
|
|
|
Integer page = 1; |
|
|
|
|
|
|
|
long timestamp = System.currentTimeMillis(); |
|
|
|
String secret = refreshTokenService.refreshToken(appKey, appSecret, govRequestTokenUrl, govRefreshTokenUrl, |
|
|
|
interfaceName, HttpMethod.POST.name()); |
|
|
|
String sign = null; |
|
|
|
try{ |
|
|
|
sign = CryptUtils.MD5Encode(appKey + secret + timestamp); |
|
|
|
}catch (Exception e){ |
|
|
|
log.error(e.getMessage()); |
|
|
|
} |
|
|
|
HttpComponentsClientHttpRequestFactory factory = HttpUtil.generateHttpRequestFactory(); |
|
|
|
RestTemplate restTemplate; |
|
|
|
if(Objects.nonNull(factory)){ |
|
|
|
restTemplate = new RestTemplate(factory); |
|
|
|
}else{ |
|
|
|
restTemplate = new RestTemplate(); |
|
|
|
} |
|
|
|
|
|
|
|
String url = coreBizUrl + "?" + |
|
|
|
"dingCode=" + orgCode + "&matterName=" + (StringUtils.isNotBlank(businessName)?businessName:StringUtils.EMPTY) + "&oid=&useState=1&" + |
|
|
|
"limit=" + (Objects.isNull(limit) ? "10" : limit) + "&page=" + (Objects.isNull(page) ? "1" : page) + |
|
|
|
"&appKey=" + appKey + "&sign=" + sign + "&requestTime=" + timestamp; |
|
|
|
|
|
|
|
ResponseEntity<JSONObject> forEntity = restTemplate.getForEntity(url, JSONObject.class); |
|
|
|
JSONObject body = forEntity.getBody(); |
|
|
|
|
|
|
|
JSONObject datas = body.getJSONObject("datas"); |
|
|
|
if(Objects.nonNull(datas)){ |
|
|
|
System.out.println(datas); |
|
|
|
} |
|
|
|
System.out.println(forEntity.getBody()); |
|
|
|
} |
|
|
|
} |