package com.stylefeng.guns.modular.system.util.MallBook.util;
|
|
import cn.hutool.core.bean.BeanUtil;
|
import cn.hutool.core.exceptions.ValidateException;
|
import cn.hutool.http.HttpUtil;
|
import cn.hutool.json.JSONUtil;
|
import com.stylefeng.guns.modular.system.util.MallBook.config.ChannelConfig;
|
import com.stylefeng.guns.modular.system.util.MallBook.model.InterfaceRequest;
|
import com.stylefeng.guns.modular.system.util.MallBook.model.InterfaceResponse;
|
|
/**
|
* @Author xiaogc
|
* @Date 2022/1/24 13:45
|
*/
|
public class TrhRequest<T> {
|
|
public InterfaceResponse execute(T t, String serverCode) {
|
InterfaceRequest<T> request = new InterfaceRequest(t, serverCode);
|
System.out.println("mallbook请求参数:" + JSONUtil.toJsonStr(request));
|
String result = HttpUtil.post(ChannelConfig.payUrl, BeanUtil.beanToMap(request));
|
System.out.println("mallbook响应参数:" + result);
|
InterfaceResponse response = JSONUtil.toBean(result, InterfaceResponse.class);
|
boolean verify = RSASignature.validate(response.content(), response.getSign());
|
if (!verify) {
|
throw new ValidateException("签名验证失败");
|
} else {
|
System.out.printf("签名验证通过");
|
}
|
return response;
|
}
|
}
|