|
@@ -5,6 +5,7 @@ import com.trade.common.utils.http.HttpClientUtils;
|
|
|
import com.trade.common.utils.http.HttpConfig;
|
|
|
import com.trade.common.utils.http.HttpHeader;
|
|
|
import com.trade.common.utils.http.StitchingUrlUtil;
|
|
|
+import com.trade.service.thirdparty.qichacha.configuration.QichachaConfiguration;
|
|
|
import com.trade.service.thirdparty.qichacha.dto.ECIResult;
|
|
|
import com.trade.service.thirdparty.qichacha.dto.EcBasicDetailDto;
|
|
|
import com.trade.service.thirdparty.qichacha.dto.EcBasicInfoDto;
|
|
@@ -13,9 +14,9 @@ import com.yomahub.liteflow.util.JsonUtil;
|
|
|
import liquibase.util.MD5Util;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
-import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import javax.annotation.Resource;
|
|
|
import java.time.Instant;
|
|
|
import java.util.Collections;
|
|
|
import java.util.HashMap;
|
|
@@ -26,10 +27,8 @@ import java.util.Map;
|
|
|
public class QichachaServiceImpl implements QichachaService {
|
|
|
|
|
|
private static final Logger logger = LoggerFactory.getLogger(QichachaServiceImpl.class);
|
|
|
- //@Value("${qichacha.api.key}")
|
|
|
- private String apiKey;
|
|
|
- //@Value("${qichacha.api.secret}")
|
|
|
- private String apiSecret;
|
|
|
+ @Resource
|
|
|
+ private QichachaConfiguration qichachaConfiguration;
|
|
|
// 企业关键字模糊查询接口
|
|
|
private static final String ECIV4_SEARCH_URL = "http://api.qichacha.com/ECIV4/Search";
|
|
|
// 410 企业工商照面
|
|
@@ -38,7 +37,7 @@ public class QichachaServiceImpl implements QichachaService {
|
|
|
@Override
|
|
|
public List<EcBasicInfoDto> findBusinessName(String keyword) {
|
|
|
Map<String, String> params = new HashMap<String, String>();
|
|
|
- params.put(ThirdpartyConstants.QCC_KEY, apiKey);
|
|
|
+ params.put(ThirdpartyConstants.QCC_KEY, qichachaConfiguration.getApiKey());
|
|
|
params.put("keyWord", keyword.replaceAll(" ", ""));
|
|
|
// 企查查权限验证参数
|
|
|
String rspStr = HttpClientUtils.get(HttpConfig.custom().url(StitchingUrlUtil.getUrl(ECIV4_SEARCH_URL, params))
|
|
@@ -53,7 +52,7 @@ public class QichachaServiceImpl implements QichachaService {
|
|
|
@Override
|
|
|
public EcBasicDetailDto getBasicDetailsByName(String keyword) {
|
|
|
Map<String, String> params = new HashMap<String, String>();
|
|
|
- params.put(ThirdpartyConstants.QCC_KEY, apiKey);
|
|
|
+ params.put(ThirdpartyConstants.QCC_KEY, qichachaConfiguration.getApiKey());
|
|
|
params.put("keyword", keyword);
|
|
|
// 企查查权限验证参数
|
|
|
String rspStr = HttpClientUtils
|
|
@@ -78,7 +77,7 @@ public class QichachaServiceImpl implements QichachaService {
|
|
|
*/
|
|
|
private String getToken() {
|
|
|
// token验证加密值(key+Timespan+SecretKey组成的32位md5加密的大写字符串)
|
|
|
- String token = apiKey + getTimespan() + apiSecret;
|
|
|
+ String token = qichachaConfiguration.getApiKey() + getTimespan() + qichachaConfiguration.getApiSecret();
|
|
|
token = MD5Util.computeMD5(token);
|
|
|
return token.toUpperCase();
|
|
|
}
|