Przeglądaj źródła

debug IRS接口

master
PoffyZhang 1 rok temu
rodzic
commit
d0d0f8580b
5 zmienionych plików z 114 dodań i 4 usunięć
  1. +2
    -2
      pmapi/src/main/java/com/ningdatech/pmapi/irs/manage/ProjectIrsManage.java
  2. +86
    -0
      pmapi/src/test/java/com/ningdatech/pmapi/irs/CoreTest.java
  3. +24
    -0
      pmapi/src/test/java/com/ningdatech/pmapi/redis/RedisTest.java
  4. +1
    -1
      pmapi/src/test/resources/application-prod.yml
  5. +1
    -1
      pmapi/src/test/resources/application.yml

+ 2
- 2
pmapi/src/main/java/com/ningdatech/pmapi/irs/manage/ProjectIrsManage.java Wyświetl plik

@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject;
import com.ningdatech.irs.service.IRefreshTokenService;
import com.ningdatech.pmapi.common.util.CryptUtils;
import com.ningdatech.pmapi.common.util.HttpUtil;
import com.ningdatech.pmapi.common.util.RefreshKeyUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
@@ -57,8 +58,7 @@ public class ProjectIrsManage {
*/
public JSONObject searchCoreBiz(String businessName,String orgCode,Integer limit,Integer page) {
long timestamp = System.currentTimeMillis();
String secret = refreshTokenService.refreshToken(appKey, appSecret, govRequestTokenUrl, govRefreshTokenUrl,
interfaceName, HttpMethod.POST.name());
String secret = RefreshKeyUtil.getRequestSecret(appKey, appSecret);
String sign = null;
try{
sign = CryptUtils.MD5Encode(appKey + secret + timestamp);


+ 86
- 0
pmapi/src/test/java/com/ningdatech/pmapi/irs/CoreTest.java Wyświetl plik

@@ -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());
}
}

+ 24
- 0
pmapi/src/test/java/com/ningdatech/pmapi/redis/RedisTest.java Wyświetl plik

@@ -0,0 +1,24 @@
package com.ningdatech.pmapi.redis;

import com.ningdatech.cache.repository.CachePlusOps;
import com.ningdatech.pmapi.AppTests;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;

/**
* @Classname RedisTest
* @Description
* @Date 2023/8/31 17:45
* @Author PoffyZhang
*/
public class RedisTest extends AppTests {

@Autowired
private CachePlusOps cachePlusOps;

@Test
public void test1(){
Object o = cachePlusOps.get("irs:A331101453557202109017383:Fc3re2cq7r64Qfa7:refresh");
System.out.println(o.toString());
}
}

+ 1
- 1
pmapi/src/test/resources/application-prod.yml Wyświetl plik

@@ -13,7 +13,7 @@ spring:
namespace: "spring:session"
redis:
timeout: 5000
host: localhost
host: 10.53.168.116
port: 6379
database: 0
password: Ndkj1234


+ 1
- 1
pmapi/src/test/resources/application.yml Wyświetl plik

@@ -1,3 +1,3 @@
spring:
profiles:
active: dev
active: prod

Ładowanie…
Anuluj
Zapisz