|
|
@@ -85,6 +85,17 @@ public class FeignClientManagerImpl extends AbstractManager implements FeignClie |
|
|
|
return handleOldSystemResponse(jsonRes, req.getResponseType(), jsonReq, req); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@Deprecated |
|
|
|
public <RE extends AbstractReqIdTypeRequest, RS> RS jsonPost(RE req, Class<RS> clazz, String ifCode, |
|
|
|
String accessToken) throws IOException { |
|
|
|
FeignCommClient client = feignClientFactory.getFeignClient(FeignCommClient.class, GATEWAY_SYSTEM.getAppId(), |
|
|
|
GATEWAY_SYSTEM.getJsonUri()); |
|
|
|
SignJsonRequest jsonReq = createReqIdJsonRequest(req, ifCode, accessToken); |
|
|
|
SignJsonResponse jsonRes = client.jsonApi(jsonReq); |
|
|
|
return handleReqIDJsonResponse(jsonRes, clazz, jsonReq, req); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public <RE extends AbstractSignTypeRequest<?>> SignJsonRequest createJsonRequest(RE req, String ifCode, |
|
|
|
String accessToken) { |
|
|
@@ -207,4 +218,53 @@ public class FeignClientManagerImpl extends AbstractManager implements FeignClie |
|
|
|
String jsonStr = jsonRes.getBizContent(); |
|
|
|
return JSONUtil.toBean(jsonStr, clazz); |
|
|
|
} |
|
|
|
/** |
|
|
|
* 通过中心平台调用,ifCode必传 |
|
|
|
*/ |
|
|
|
@Deprecated |
|
|
|
private <RE extends AbstractReqIdTypeRequest> SignJsonRequest createReqIdJsonRequest(RE req, String ifCode, |
|
|
|
String accessToken) throws EncryptException { |
|
|
|
if (!hasText(ifCode)) { |
|
|
|
throw new ApiRequestException("ifCode IS NULL", FileProtocolSystemError.SIGN_FAILED.getCode()); |
|
|
|
} |
|
|
|
|
|
|
|
String reqId = commConfig.getAppId() + "_" + LocalDateTime.now().format(TimeTools.yyyyMMddHHmmssSSS) + "_" |
|
|
|
+ RandomStringUtils.randomNumeric(5); |
|
|
|
req.setReqId(reqId); |
|
|
|
SignJsonRequest jsonReq = new SignJsonRequest(); |
|
|
|
jsonReq.setAppId(commConfig.getAppId()); |
|
|
|
jsonReq.setIfCode(ifCode); |
|
|
|
jsonReq.setReqId(reqId); |
|
|
|
jsonReq.setTimestamp(LocalDateTime.now().format(TimeTools.ISO_LOCAL_DATE_TIME)); |
|
|
|
jsonReq.setEncryptType(commConfig.getEncryptType()); |
|
|
|
jsonReq.setSignType(commConfig.getSignType()); |
|
|
|
jsonReq.setBizContent(req.toJson()); |
|
|
|
if (hasText(accessToken)) { |
|
|
|
jsonReq.setAccessToken(accessToken); |
|
|
|
} |
|
|
|
jsonReq.setSign(jsonReq.toSignContent(commConfig.getServerPublicKey())); |
|
|
|
return jsonReq; |
|
|
|
} |
|
|
|
@Deprecated |
|
|
|
private <RE extends AbstractReqIdTypeRequest, RS> RS handleReqIDJsonResponse(SignJsonResponse jsonRes, |
|
|
|
Class<RS> clazz, SignJsonRequest jsonReq, RE req) throws IOException { |
|
|
|
if (jsonRes == null) { |
|
|
|
logger.error("jsonRes is null ifCode:{},reqId:{}", jsonReq.getIfCode(), jsonReq.getReqId()); |
|
|
|
SignJsonResponse rs = new SignJsonResponse(FileProtocolSystemError.UNKNOWN_ERROR.getCode(), "调用接口返回空"); |
|
|
|
throw new ApiRequestException(rs.toJson(), rs.getStatusCode()); |
|
|
|
} |
|
|
|
if (SignJsonResponse.SUCCESS_CODE != jsonRes.getStatusCode()) { |
|
|
|
throw new ApiRequestException(jsonRes.toJson(), jsonRes.getStatusCode()); |
|
|
|
} |
|
|
|
// 成功时返回具体类型 |
|
|
|
RS rs = decryptReqIdBizContent(jsonRes, clazz, req); |
|
|
|
|
|
|
|
boolean verifyResult = verify(commConfig.getServerPublicKey(), null, jsonRes.getSign()); |
|
|
|
if (!verifyResult) { |
|
|
|
throw new ApiRequestException("处理返回时验签失败:" + jsonReq.getReqId(), |
|
|
|
FileProtocolSystemError.SIGN_FAILED.getCode()); |
|
|
|
} |
|
|
|
return rs; |
|
|
|
|
|
|
|
} |
|
|
|
} |