//package cn.van.business.erp.request;
//
//import com.fasterxml.jackson.core.JsonProcessingException;
//import com.fasterxml.jackson.databind.ObjectMapper;
//
//import java.nio.charset.StandardCharsets;
//import java.security.MessageDigest;
//import java.security.NoSuchAlgorithmException;
//
//public abstract class ERPRequestBase {
//    protected final String url;
//    protected final ERPAccount erpAccount;
//    protected final Object requestBody;
//
//    public ERPRequestBase(String url, ERPAccount erpAccount, Object requestBody) {
//        this.url = url;
//        this.erpAccount = erpAccount;
//        this.requestBody = requestBody;
//    }
//
//    public String getUrl() {
//        return url;
//    }
//
//    public ERPAccount getErpAccount() {
//        return erpAccount;
//    }
//
//    public abstract String getRequestBodyAsString();
//
//    protected String genMd5(String str) {
//        StringBuilder result = new StringBuilder();
//        try {
//            MessageDigest md = MessageDigest.getInstance("MD5");
//            byte[] digest = md.digest(str.getBytes(StandardCharsets.UTF_8));
//            for (byte b : digest) {
//                result.append(String.format("%02x", b & 0xff));
//            }
//        } catch (NoSuchAlgorithmException e) {
//            throw new RuntimeException(e);
//        }
//        return result.toString();
//    }
//
//    protected String genSign(long timestamp, String jsonStr) {
//        String data = erpAccount.getApiKey() + "," + genMd5(jsonStr) + "," + timestamp + "," + erpAccount.getApiKeySecret();
//        return genMd5(data);
//    }
//}
