|
|
@@ -5,6 +5,7 @@ import java.util.Date;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.Map;
|
|
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
@@ -16,6 +17,7 @@ import cn.hutool.crypto.digest.HmacAlgorithm;
|
|
|
import cn.hutool.http.HttpRequest;
|
|
|
import cn.hutool.http.HttpUtil;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import me.zhengjie.application.admin.service.DictDetailService;
|
|
|
import me.zhengjie.base.util.UUIDGenerator;
|
|
|
|
|
|
import me.zhengjie.dao.mybatis.entity.OrderCochainEntity;
|
|
|
@@ -25,28 +27,35 @@ import me.zhengjie.dao.mybatis.entity.OrderCochainEntity;
|
|
|
public class CochainService {
|
|
|
// appid: ntgzcycb01
|
|
|
// appsecret: caf91ca41ef87e8acaad5cc16390c5eeb4ddbb8ab70eec8703c621b9e5ee4e98
|
|
|
- public static final String APP_ID = "ntgzcycb01";
|
|
|
- public static final String APP_SECRET = "caf91ca41ef87e8acaad5cc16390c5eeb4ddbb8ab70eec8703c621b9e5ee4e98";
|
|
|
- public static final String PRODUCE = "http://58.240.76.108:9080/produce";
|
|
|
+ @Autowired
|
|
|
+ DictDetailService dictDetailService;
|
|
|
|
|
|
- public static final String COCHAIN = "http://221.6.10.202:8051/cochain";
|
|
|
+ public static String APP_ID;
|
|
|
+ public static String APP_SECRET;
|
|
|
+ public static String PRODUCE;
|
|
|
+
|
|
|
+ public static String COCHAIN;
|
|
|
+
|
|
|
+ public String sha1_HMAC(String message) {
|
|
|
|
|
|
- public static String sha1_HMAC(String message) {
|
|
|
HMac mac = new HMac(HmacAlgorithm.HmacSHA1, APP_SECRET.getBytes());
|
|
|
String macHex1 = mac.digestHex(message);
|
|
|
return macHex1;
|
|
|
}
|
|
|
|
|
|
public String getKey(String taskId) {
|
|
|
+ Map<String, String> dictMap = dictDetailService.getValueByName("cochain");
|
|
|
+ PRODUCE = dictMap.get("produce");
|
|
|
+ APP_SECRET = dictMap.get("app_secret");
|
|
|
+ APP_ID = dictMap.get("app_id");
|
|
|
+ COCHAIN = dictMap.get("cochain_url");
|
|
|
Map<String, String> params = new HashMap<>();
|
|
|
params.put("app_id", APP_ID);
|
|
|
params.put("task_id", taskId);
|
|
|
String json = JSON.toJSONString(params);
|
|
|
System.out.print(json);
|
|
|
String base64 = Base64.encode(json.getBytes(StandardCharsets.UTF_8));
|
|
|
- System.out.print(base64);
|
|
|
String my = sha1_HMAC(base64);
|
|
|
- System.out.print(my);
|
|
|
Map<String, String> dict = new HashMap<>();
|
|
|
dict.put("content", base64);
|
|
|
dict.put("signature", my);
|
|
|
@@ -94,7 +103,7 @@ public class CochainService {
|
|
|
String json = JSON.toJSONString(data);
|
|
|
String base64encodedString = Base64.encode(json);
|
|
|
System.out.println("Base64 编码字符串(基本):" + base64encodedString);
|
|
|
- String sha = sha1_HMAC(base64encodedString);
|
|
|
+ String sha = "";// sha1_HMAC(base64encodedString);
|
|
|
JSONObject content = new JSONObject();
|
|
|
content.put("content", base64encodedString);
|
|
|
content.put("signature", sha);
|