Browse Source

添加注释

master
yechuan 1 year ago
parent
commit
44bc851f68
5 changed files with 38 additions and 60 deletions
  1. +30
    -0
      common/src/main/java/work/xuye/common/db/entity/vo/NextTaskFilter.java
  2. +3
    -0
      common/src/main/java/work/xuye/common/db/entity/vo/SinkParams.java
  3. +3
    -0
      common/src/main/java/work/xuye/common/db/entity/vo/TaskMiniVO.java
  4. +0
    -59
      common/src/main/java/work/xuye/common/utils/SignatureUtil.java
  5. +2
    -1
      source/src/main/java/work/xuye/source/handler/SourceHandler.java

+ 30
- 0
common/src/main/java/work/xuye/common/db/entity/vo/NextTaskFilter.java View File

@@ -15,18 +15,48 @@ import java.util.Map;
@NoArgsConstructor
@AllArgsConstructor
public class NextTaskFilter {
/**
* 参与计算的jsonPath
*/
private String filterArgs;

/**
* break 表示命中后不再继续尝试匹配其他的节点
*/
private String mode;

/**
* 当前的唯一key,用于缓存判断是否变更
*/
private String uniqueKey;

/**
* 后继节点配置
*/
private List<NextNodeConfig> nextNodes;

/**
* spel表达式
*/
private Map<String, String> placeholderExpressions = Map.of();

@Data
@NoArgsConstructor
@AllArgsConstructor
public static class NextNodeConfig {
/**
* 消息往哪里个topic发 以通知后继任务执行
*/
private String topic;

/**
* 需要满足的条件
*/
private String condition;

/**
* 发送的对象
*/
private String payload;
}
}

+ 3
- 0
common/src/main/java/work/xuye/common/db/entity/vo/SinkParams.java View File

@@ -50,6 +50,9 @@ public class SinkParams {
private Status status;
private String fieldName;
private String jsonPath;
/**
* 数据库对象转化为String的spel表达式
*/
private String dbObjectExpression;
}



+ 3
- 0
common/src/main/java/work/xuye/common/db/entity/vo/TaskMiniVO.java View File

@@ -21,5 +21,8 @@ public class TaskMiniVO {

private String name;

/**
* 用于存储父task节点发送的参数 子节点可能需要此参数进行计算
*/
private Map<String, String> args;
}

+ 0
- 59
common/src/main/java/work/xuye/common/utils/SignatureUtil.java View File

@@ -1,59 +0,0 @@
package work.xuye.common.utils;

import org.apache.commons.codec.binary.Base64;
import org.springframework.stereotype.Component;
import org.springframework.util.DigestUtils;
import work.xuye.common.dto.HttpRequestParams;

import java.nio.charset.StandardCharsets;
import java.security.KeyFactory;
import java.security.PrivateKey;
import java.security.Signature;
import java.security.spec.PKCS8EncodedKeySpec;

/**
* @author yechuan
* @since 2023/8/7 15:08
**/
@Component
public class SignatureUtil {

private final static String privateKey = "MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBANTyWsgvVOW6lNH4\n" +
"koggbORNIdM0mw+klkTfAZJ8hM9SvxaPWgo55dU1zp46nUs15ZStf/A4EmOeh4jA\n" +
"SLqHf3Zd2WJc5izjEm70pnwHXRCjOA8i4nR6ia0fpzZPf+FNqElmvsfrvqk185cf\n" +
"kAXk2RoXSAykUi+2UMK6TlTaHmqXAgMBAAECgYAmCFcQc+us0CMuUUASkgAA0ond\n" +
"CAM9yv6PtGi6egTaZoP8ioPhWa/j4aVSe1OGkEy9vjMge1NFeZXpZbZXokWwUdmi\n" +
"xxOcCYgYKebJ0Fmssvj/GSRL93B1JlXs88MdedAGlef1b1IyURUSDbkkbOZmHnON\n" +
"OgkoSafcB+JFx6Ea8QJBAPTaiAZSsco9e23EMXfhy+h7CjYYY8LJ+gBrnEZV2jns\n" +
"O7i2W/2c9sEzexG8C/W1oEbEDsfkmCKvf/mQ+dJb0d8CQQDeo/yuk5Z0W+yBos5U\n" +
"h0vjlAJzVL812QNv02bogmGaS7y3Ao1+/cVeTWSrlEjjM2tcbnpFtOgFtLBl1lFX\n" +
"9q5JAkB6gskimMe6UC7sygiSWhjjdoSycluf/90lzrH/gz9QUgHDtwKqD5prKq3+\n" +
"Pp+hTkImhjx7CcaRPEyE+2P0O9rzAkEAq2XJgEhkmn2uDHrepxplZPUsEcebUIQZ\n" +
"7jvsTHEbXKKTzLwtXCdXi2q/ZovItQh/zW/Lt+A2gzYAWtXsV3Cz6QJBAJUTb8kM\n" +
"5iUYlWupmS6kOSfYFOqrVvI3w9kZUocsxv338dpzuKxikkIxAfiBTtbVXawEkF48\n" +
"tTSQsDJmnXj2Hhw=";



public String signature(String content) throws Exception {

byte[] decode = Base64.decodeBase64(privateKey);
PKCS8EncodedKeySpec priPKCS8 = new PKCS8EncodedKeySpec(decode);
PrivateKey priKey = KeyFactory.getInstance("RSA").generatePrivate(priPKCS8);
String md5 = DigestUtils.md5DigestAsHex(content.getBytes(StandardCharsets.UTF_8)).toUpperCase();
Signature signature = Signature.getInstance("SHA1WithRSA");
signature.initSign(priKey);
signature.update(md5.getBytes(StandardCharsets.UTF_8));
return Base64.encodeBase64String(signature.sign()).trim();
}

public String packageContent(HttpRequestParams params, String timestamp, String body) {
return "ENCRYPT-ALGORITHM" + "=" + "RSA" +
"&" +
"PARAMS" + "=" + body +
"&" +
"TIMESTAMP" + "=" + timestamp;

}

}

+ 2
- 1
source/src/main/java/work/xuye/source/handler/SourceHandler.java View File

@@ -162,7 +162,7 @@ public class SourceHandler {

private Map<String, Message> buildNextNodeMessage(List<HttpRes> result, Task task, Message<TaskMiniVO> message) {
NextTaskFilter filter = task.getNextFilter();
Set<String> otherCacheKeySet = new HashSet<>();
Map<String, Message> resultMap = new HashMap<>();
result.stream()
.map(item -> {
@@ -221,6 +221,7 @@ public class SourceHandler {
if (!Boolean.TRUE.equals(getPlaceholderSpel(nextNode.getCondition(), filter.getPlaceholderExpressions(), context, Boolean.class))) {
continue;
}
Set<String> otherCacheKeySet = new HashSet<>();
otherCacheKeySet.add(uniqueKey);
// 命中
String topic = getPlaceholderSpel(nextNode.getTopic(), filter.getPlaceholderExpressions(), context, String.class);


Loading…
Cancel
Save