| | |
| | | import com.supersavedriving.user.modular.system.util.MallBook.config.ChannelConfig; |
| | | import com.supersavedriving.user.modular.system.util.MallBook.model.InterfaceRequest; |
| | | import com.supersavedriving.user.modular.system.util.MallBook.model.InterfaceResponse; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | |
| | | /** |
| | | * @Author xiaogc |
| | |
| | | */ |
| | | public class TrhRequest<T> { |
| | | |
| | | Logger logger = LoggerFactory.getLogger("ServiceLog"); |
| | | |
| | | public InterfaceResponse execute(T t, String serverCode) { |
| | | InterfaceRequest<T> request = new InterfaceRequest(t, serverCode); |
| | | System.out.println("mallbook请求参数:" + JSONUtil.toJsonStr(request)); |
| | | logger.warn("mallbook请求参数:" + JSONUtil.toJsonStr(request)); |
| | | String result = HttpUtil.post(ChannelConfig.payUrl, BeanUtil.beanToMap(request)); |
| | | System.out.println("mallbook响应参数:" + result); |
| | | logger.warn("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("签名验证通过"); |
| | | logger.warn("签名验证通过"); |
| | | } |
| | | return response; |
| | | } |