|
@ -48,7 +48,16 @@ public class ZysoftBaseService {
|
|
|
* @return
|
|
|
*/
|
|
|
private String getBaseApi(Integer apiType){
|
|
|
return "wlw";
|
|
|
String baseApi = "";
|
|
|
switch (apiType){
|
|
|
case 0:
|
|
|
baseApi = "/wlw/accesstoken";
|
|
|
break;
|
|
|
default:
|
|
|
baseApi = "";
|
|
|
break;
|
|
|
}
|
|
|
return baseApi;
|
|
|
}
|
|
|
|
|
|
|
|
@ -208,58 +217,46 @@ public class ZysoftBaseService {
|
|
|
* YG请求 新的公钥和私钥
|
|
|
*/
|
|
|
public String postSecondYg(String api,String content, Map<String,String> params,JSONObject jsonParams, Map<String,String> headers,
|
|
|
boolean needRetry,Integer apiType,String type) throws Exception
|
|
|
boolean needRetry,Integer apiType) throws Exception
|
|
|
{
|
|
|
String re = "";
|
|
|
headers.put("INTERFACE",api);
|
|
|
|
|
|
Map<String,String> paramsList = new HashMap<>();
|
|
|
String msgBody = params==null?JSONObject.toJSONString(jsonParams, SerializerFeature.WriteMapNullValue):
|
|
|
JSONObject.toJSONString(params, SerializerFeature.WriteMapNullValue);
|
|
|
String msgHeader = JSONObject.toJSONString(headers, SerializerFeature.WriteMapNullValue);
|
|
|
paramsList.put("msgHeader",msgHeader);
|
|
|
paramsList.put("msgBody",msgBody);
|
|
|
|
|
|
logger.info("msgHeader:"+msgHeader+"\r\n");
|
|
|
logger.info("msgBody:"+msgBody+"\r\n");
|
|
|
|
|
|
//新增日志
|
|
|
String method = "POST";
|
|
|
Boolean isSuccess = true;
|
|
|
String error = "";
|
|
|
String msgBody = params==null?JSONObject.toJSONString(jsonParams, SerializerFeature.WriteMapNullValue):
|
|
|
JSONObject.toJSONString(params, SerializerFeature.WriteMapNullValue);
|
|
|
|
|
|
String baseApi = getBaseApi(apiType);
|
|
|
|
|
|
int times = 0;
|
|
|
try {
|
|
|
re = ZysoftApiSeconde.getSingleton().post(baseApi, paramsList, null,openCrypto,"SM2_V2",headers.get("LICENCE").toString());
|
|
|
re = ZysoftApiSeconde.getSingleton().post(baseApi, params, null,openCrypto,"SM2_V2", headers.get("LICENCE"));
|
|
|
if(needRetry)
|
|
|
{
|
|
|
int maxTimes = retryTimes;
|
|
|
while(maxTimes>0 && re.contains("接口调用传入的参数[msgHeader]格式不正确")) //基卫bug预防,重调接口
|
|
|
{
|
|
|
re = ZysoftApiSeconde.getSingleton().post(baseApi, paramsList, null,openCrypto,"SM2_V2",headers.get("LICENCE").toString());
|
|
|
re = ZysoftApiSeconde.getSingleton().post(baseApi, params, null,openCrypto,"SM2_V2", headers.get("LICENCE"));
|
|
|
maxTimes --;
|
|
|
times++;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
logger.info("=====接口返回============="+re);
|
|
|
Map<String,String> map = objectMapper.readValue(re,Map.class);
|
|
|
String code = map.get("CODE");
|
|
|
|
|
|
if(!code.equals("1"))
|
|
|
if(!"1".equals(code)&&code!=null)
|
|
|
{
|
|
|
throw new HttpApiException(Integer.valueOf(code),map.get("MESSAGE"));
|
|
|
throw new HttpApiException(Integer.parseInt(code),map.get("MESSAGE"));
|
|
|
}
|
|
|
//保存http日志
|
|
|
logService.saveHttpLog(isSuccess,api,content,method,msgHeader,msgBody,re,error);
|
|
|
logService.saveHttpLog(isSuccess,api,content,method,msgBody,re,error);
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
ex.printStackTrace();
|
|
|
|
|
|
//保存http日志
|
|
|
logService.saveHttpLog(isSuccess,api,content,method,msgHeader,msgBody,re,error);
|
|
|
logService.saveHttpLog(isSuccess,api,content,method,msgBody,re,error);
|
|
|
|
|
|
if(ex instanceof ApiException)
|
|
|
{
|