优化调解功能
This commit is contained in:
@@ -0,0 +1,72 @@
|
||||
package com.ruoyi.wisdomarbitrate.utils;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.crypto.digest.HMac;
|
||||
import cn.hutool.crypto.digest.HmacAlgorithm;
|
||||
import cn.hutool.http.HttpRequest;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.wisdomarbitrate.domain.entity.mscase.MsCaseApplication;
|
||||
import com.ruoyi.wisdomarbitrate.domain.vo.mscase.CaseApplicationVO;
|
||||
import com.ruoyi.wisdomarbitrate.domain.vo.mscase.MsCaseApplicationVO;
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
public class SignCheckUtils {
|
||||
public static String getSign(String paramsbody, String accessSec, long timestamp) {
|
||||
String paramsStr = getParamsStr(paramsbody, timestamp);
|
||||
return generateSign(paramsStr, accessSec);
|
||||
}
|
||||
|
||||
public static String getParamsStr(String paramsbody,long timestamp) {
|
||||
StringBuilder strbuild = new StringBuilder();
|
||||
if (StringUtils.isNotBlank(paramsbody)) {
|
||||
strbuild.append(paramsbody).append('#');
|
||||
}
|
||||
strbuild.append("#timestamp=").append(timestamp);
|
||||
return strbuild.toString();
|
||||
}
|
||||
|
||||
public static String generateSign(String paramsStr, String accessSec) {
|
||||
HMac hMac = new HMac(HmacAlgorithm.HmacSHA256, accessSec.getBytes(StandardCharsets.UTF_8));
|
||||
return hMac.digestHex(paramsStr);
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
String accessSec = "mCFMA6ffe938v79m";
|
||||
MsCaseApplicationVO application = new MsCaseApplicationVO();
|
||||
application.setArbitratClaims("1111");
|
||||
application.setCaseStatusName("222");
|
||||
application.setCaseNum("234566");
|
||||
|
||||
CaseApplicationVO caseApplicationVO = new CaseApplicationVO();
|
||||
BeanUtils.copyProperties(application,caseApplicationVO);
|
||||
boolean importFlag = application.isImportFlag();
|
||||
if(importFlag==true){
|
||||
caseApplicationVO.setImportFlag(1);
|
||||
}else {
|
||||
caseApplicationVO.setImportFlag(0);
|
||||
}
|
||||
|
||||
|
||||
String paramsbody = JSONUtil.toJsonStr(caseApplicationVO);
|
||||
long timestamp = System.currentTimeMillis();
|
||||
String signStr = getSign(paramsbody, accessSec, timestamp);
|
||||
String urlstr = "http://localhost:8001/callArbitrateCaseApplication/generateCaseApplication";
|
||||
HttpResponse httpResponse = (HttpResponse) HttpRequest.post(urlstr)
|
||||
.header("timestampstr", String.valueOf(timestamp))
|
||||
.header("signstr", signStr)
|
||||
.body(paramsbody)
|
||||
.execute();
|
||||
System.out.println(httpResponse);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user