|
|
@ -2,10 +2,8 @@ package com.epmet.apiservice; |
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
import com.epmet.apiservice.result.LZGridPlatformBaseResult; |
|
|
|
import com.epmet.dto.form.UploadFileFormDTO; |
|
|
|
import com.epmet.commons.tools.redis.RedisKeys; |
|
|
|
import com.epmet.dto.result.ProjectAssistResult; |
|
|
|
import com.epmet.commons.tools.exception.RenException; |
|
|
|
import com.epmet.commons.tools.redis.RedisKeys; |
|
|
|
import com.epmet.commons.tools.utils.HttpClientManager; |
|
|
|
import com.epmet.commons.tools.utils.Result; |
|
|
|
import com.epmet.commons.tools.utils.SpringContextUtils; |
|
|
@ -14,10 +12,13 @@ import com.epmet.dao.ThirdplatformCustomerRegisterDao; |
|
|
|
import com.epmet.dao.ThirdplatformDao; |
|
|
|
import com.epmet.dto.form.ProjectApplyAssistFormDTO; |
|
|
|
import com.epmet.dto.form.TPFDemoFormDTO; |
|
|
|
import com.epmet.dto.form.UploadFileFormDTO; |
|
|
|
import com.epmet.dto.result.ProjectAssistResult; |
|
|
|
import com.epmet.dto.result.UploadFileResultDTO; |
|
|
|
import com.epmet.entity.ThirdplatformActionEntity; |
|
|
|
import com.epmet.entity.ThirdplatformCustomerRegisterEntity; |
|
|
|
import com.epmet.entity.ThirdplatformEntity; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.springframework.data.redis.core.RedisTemplate; |
|
|
|
|
|
|
|
import java.io.File; |
|
|
@ -30,6 +31,7 @@ import java.util.concurrent.TimeUnit; |
|
|
|
* 每一个具体平台的ApiService都是该抽象类的子类,选择性实现抽象类中的某些需要实现方法,提供具体业务逻辑 |
|
|
|
* 此抽象类中定义方法的具体返回类型,所有子类都要统一使用,在具体实现中做转换。若是不需要返回,返回null即可。 |
|
|
|
*/ |
|
|
|
@Slf4j |
|
|
|
public abstract class ApiService { |
|
|
|
/** |
|
|
|
* 重试次数 |
|
|
@ -73,12 +75,12 @@ public abstract class ApiService { |
|
|
|
|
|
|
|
// 填充access token到头当中
|
|
|
|
headers.put("X-Access-Token", accessToken); |
|
|
|
|
|
|
|
log.info("apiService sendGetRequest param:{},headers:{}",params,headers); |
|
|
|
Result<String> result = HttpClientManager.getInstance().sendGet(thirdplatform.getBaseUrl().concat(actionEntity.getApiUrl()), |
|
|
|
thirdplatform.getBaseUrl().startsWith("https://"), |
|
|
|
params, |
|
|
|
headers); |
|
|
|
|
|
|
|
log.info("apiService sendGetRequest result:{}",JSON.toJSONString(result)); |
|
|
|
if (result == null) { |
|
|
|
throw new RenException("请求第三方平台,获取AccessToken失败。result为null"); |
|
|
|
} |
|
|
@ -113,11 +115,12 @@ public abstract class ApiService { |
|
|
|
// 填充access token到头当中
|
|
|
|
headers.put("X-Access-Token", accessToken); |
|
|
|
|
|
|
|
log.info("apiService sendPostRequest param:{},headers:{}",jsonString,headers); |
|
|
|
Result<String> result = HttpClientManager.getInstance().sendPost(thirdplatform.getBaseUrl().concat(actionEntity.getApiUrl()), |
|
|
|
thirdplatform.getBaseUrl().startsWith("https://"), |
|
|
|
jsonString, |
|
|
|
headers); |
|
|
|
|
|
|
|
log.info("apiService sendPostRequest result:{}",JSON.toJSONString(result)); |
|
|
|
if (result == null) { |
|
|
|
throw new RenException("请求第三方平台,发送Post请求失败。result为null"); |
|
|
|
} |
|
|
@ -142,13 +145,13 @@ public abstract class ApiService { |
|
|
|
|
|
|
|
// 填充access token到头当中
|
|
|
|
headers.put("X-Access-Token", accessToken); |
|
|
|
|
|
|
|
log.info("apiService sendPostRequestToUploadFile fileName:{}",headers); |
|
|
|
Result<String> result = HttpClientManager.getInstance().uploadFile(thirdplatform.getBaseUrl().concat(actionEntity.getApiUrl()), |
|
|
|
thirdplatform.getBaseUrl().startsWith("https://"), |
|
|
|
file, |
|
|
|
fileName, |
|
|
|
headers); |
|
|
|
|
|
|
|
log.info("apiService sendPostRequestToUploadFile result:{}",JSON.toJSONString(result)); |
|
|
|
if (result == null) { |
|
|
|
throw new RenException("请求第三方平台,发送Post请求失败。result为null"); |
|
|
|
} |
|
|
|