|
@@ -3,6 +3,7 @@ package com.trade.service.thirdparty.xiaotu.service.impl;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import com.alibaba.fastjson2.JSON;
|
|
|
import com.alibaba.fastjson2.JSONObject;
|
|
|
+import com.alibaba.fastjson2.TypeReference;
|
|
|
import com.trade.common.constant.CacheConstants;
|
|
|
import com.trade.common.redis.RedisCache;
|
|
|
import com.trade.common.utils.http.HttpClientUtils;
|
|
@@ -17,6 +18,7 @@ import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import java.util.List;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
@Service
|
|
@@ -139,4 +141,42 @@ public class XiaotuRequestServiceImpl implements XiaotuRequestService {
|
|
|
}
|
|
|
return commonResponse.getBody();
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 小图通用查询接口 - 带分页
|
|
|
+ *
|
|
|
+ * @param request 请求参数
|
|
|
+ * @param <T> 返回类型
|
|
|
+ * @return List<T>
|
|
|
+ */
|
|
|
+ public <T extends CommonResultRows> CommonQueryResponse<T> queryCommonResponse(CommonQueryRequest request) {
|
|
|
+ String resp = HttpClientUtils
|
|
|
+ .post(HttpConfig.custom().headers(getCommonHeader().contentType(CONTENT_TYPE_JSON).build())
|
|
|
+ .json(JSON.toJSONString(request)).url(request.getUrl()));
|
|
|
+ CommonResponse<?> commonResponse = JSON.parseObject(resp, CommonResponse.class);
|
|
|
+ logger.info("查询小图数据,req={},resp={}", request, resp);
|
|
|
+ if (commonResponse == null || !commonResponse.isSuccess()) {
|
|
|
+ throw new RuntimeException("查询小图数据失败");
|
|
|
+ }
|
|
|
+ return JSON.parseObject((String) commonResponse.getBody(), new TypeReference<CommonQueryResponse<T>>() {
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 小图通用查询接口 - 仅返回rows
|
|
|
+ *
|
|
|
+ * @param request 请求参数
|
|
|
+ * @param <T> 返回类型
|
|
|
+ * @return List<T>
|
|
|
+ */
|
|
|
+ public <T extends CommonResultRows> List<T> queryCommonResponseRows(CommonQueryRequest request) {
|
|
|
+ CommonQueryResponse<T> commonQueryResponse = queryCommonResponse(request);
|
|
|
+ return commonQueryResponse.getRows();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<CustomsDeclarationResponse> customsDeclarationInquiry(CustomsDeclarationRequest request) {
|
|
|
+ request.setUrl(xiaotuConfiguration.getCustomsDeclarationUrl());
|
|
|
+ return queryCommonResponseRows(request);
|
|
|
+ }
|
|
|
}
|