|
|
@@ -1,6 +1,13 @@
|
|
|
package com.shkpr.service.customgateway.zydma.constants;
|
|
|
|
|
|
import com.shkpr.service.customgateway.core.constants.IntegrationMetadata;
|
|
|
+import com.shkpr.service.customgateway.core.domain.IntegrationKey;
|
|
|
+import org.apache.commons.codec.digest.DigestUtils;
|
|
|
+
|
|
|
+import java.time.LocalDateTime;
|
|
|
+import java.time.ZoneId;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* 中台集成元数据
|
|
|
@@ -8,32 +15,65 @@ import com.shkpr.service.customgateway.core.constants.IntegrationMetadata;
|
|
|
* @author 欧阳劲驰
|
|
|
* @since 1.0.0
|
|
|
*/
|
|
|
-public interface MiddlePlatformMetadata extends IntegrationMetadata {
|
|
|
+public abstract class MiddlePlatformMetadata extends IntegrationMetadata {
|
|
|
//系统名称
|
|
|
- String NAME = "middlePlatform";
|
|
|
+ public static String NAME = "middlePlatform";
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取密钥
|
|
|
+ *
|
|
|
+ * @param accessKey 公钥
|
|
|
+ * @param secretKey 私钥
|
|
|
+ * @param params 参数
|
|
|
+ * @return 密钥
|
|
|
+ */
|
|
|
+ public static IntegrationKey getKey(String accessKey, String secretKey, Map<String, String> params) {
|
|
|
+ //时间戳
|
|
|
+ long timestamp = LocalDateTime.now().atZone(ZoneId.systemDefault()).toInstant().toEpochMilli();
|
|
|
+ //连接参数
|
|
|
+ String paramsStr = params.entrySet().stream()
|
|
|
+ .map(entry -> entry.getKey() + "=" + entry.getValue())
|
|
|
+ .collect(Collectors.joining("&"));
|
|
|
+ //签名密钥
|
|
|
+ String sign = DigestUtils.md5Hex(secretKey + "&" + timestamp + "&" + paramsStr).toUpperCase();
|
|
|
+ return new IntegrationKey(timestamp, accessKey, secretKey, sign, null);
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* 接口地址
|
|
|
*/
|
|
|
- interface Uri {
|
|
|
+ public interface Uri {
|
|
|
//获取用户
|
|
|
String GET_USERS = "/IntegrationAuth/GetUsers";
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * 头
|
|
|
+ */
|
|
|
+ public interface Headers {
|
|
|
+ //密钥
|
|
|
+ String APP_KEY = "appKey";
|
|
|
+ //时间戳
|
|
|
+ String TIMESTAMP = "timestamp";
|
|
|
+ //签名
|
|
|
+ String SIGN = "sign";
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* 参数
|
|
|
*/
|
|
|
- interface Params {
|
|
|
+ public interface Params {
|
|
|
//页码
|
|
|
String PAGE_NUMBER = "pageIndex";
|
|
|
//分页大小
|
|
|
String PAGE_SIZE = "pageSize";
|
|
|
}
|
|
|
|
|
|
+
|
|
|
/**
|
|
|
* 默认值
|
|
|
*/
|
|
|
- interface DefaultValues {
|
|
|
+ public interface DefaultValues {
|
|
|
//角色id
|
|
|
String ROLE_ID = "255";
|
|
|
//组织
|