mirror of
https://gitee.com/dromara/liteFlow.git
synced 2026-05-14 04:02:09 +08:00
bug #IBTZIX bind关键字无法反序列化LocalDate类型
This commit is contained in:
@@ -31,6 +31,10 @@
|
|||||||
<groupId>com.fasterxml.jackson.core</groupId>
|
<groupId>com.fasterxml.jackson.core</groupId>
|
||||||
<artifactId>jackson-databind</artifactId>
|
<artifactId>jackson-databind</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.fasterxml.jackson.datatype</groupId>
|
||||||
|
<artifactId>jackson-datatype-jsr310</artifactId>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.yaml</groupId>
|
<groupId>org.yaml</groupId>
|
||||||
<artifactId>snakeyaml</artifactId>
|
<artifactId>snakeyaml</artifactId>
|
||||||
|
|||||||
@@ -7,14 +7,12 @@ import com.fasterxml.jackson.databind.DeserializationFeature;
|
|||||||
import com.fasterxml.jackson.databind.JsonNode;
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import com.fasterxml.jackson.databind.type.CollectionType;
|
import com.fasterxml.jackson.databind.type.CollectionType;
|
||||||
|
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
||||||
import com.yomahub.liteflow.exception.JsonProcessException;
|
import com.yomahub.liteflow.exception.JsonProcessException;
|
||||||
import com.yomahub.liteflow.log.LFLog;
|
import com.yomahub.liteflow.log.LFLog;
|
||||||
import com.yomahub.liteflow.log.LFLoggerManager;
|
import com.yomahub.liteflow.log.LFLoggerManager;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.TimeZone;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* JSON 工具类
|
* JSON 工具类
|
||||||
@@ -33,6 +31,8 @@ public class JsonUtil {
|
|||||||
static {
|
static {
|
||||||
objectMapper.setTimeZone(TimeZone.getDefault());
|
objectMapper.setTimeZone(TimeZone.getDefault());
|
||||||
objectMapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
|
objectMapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
|
||||||
|
JavaTimeModule javaTimeModule = new JavaTimeModule();
|
||||||
|
objectMapper.registerModule(javaTimeModule);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String toJsonString(Object object) {
|
public static String toJsonString(Object object) {
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import com.yomahub.liteflow.core.FlowExecutor;
|
|||||||
import com.yomahub.liteflow.flow.LiteflowResponse;
|
import com.yomahub.liteflow.flow.LiteflowResponse;
|
||||||
import com.yomahub.liteflow.slot.DefaultContext;
|
import com.yomahub.liteflow.slot.DefaultContext;
|
||||||
import com.yomahub.liteflow.test.BaseTest;
|
import com.yomahub.liteflow.test.BaseTest;
|
||||||
|
import com.yomahub.liteflow.util.JsonUtil;
|
||||||
import org.junit.jupiter.api.Assertions;
|
import org.junit.jupiter.api.Assertions;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||||
@@ -12,6 +13,7 @@ import org.springframework.context.annotation.ComponentScan;
|
|||||||
import org.springframework.test.context.TestPropertySource;
|
import org.springframework.test.context.TestPropertySource;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* springboot环境EL常规的例子测试
|
* springboot环境EL常规的例子测试
|
||||||
@@ -71,4 +73,14 @@ public class BindDataSpringbootTest1 extends BaseTest {
|
|||||||
Assertions.assertEquals("test2", context.getData("c"));
|
Assertions.assertEquals("test2", context.getData("c"));
|
||||||
Assertions.assertTrue(response.isSuccess());
|
Assertions.assertTrue(response.isSuccess());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 测试bind一个对象,并且对象中的birth类型为LocalDate
|
||||||
|
@Test
|
||||||
|
public void testBind5() throws Exception {
|
||||||
|
LiteflowResponse response = flowExecutor.execute2Resp("chain5", "arg");
|
||||||
|
DefaultContext context = response.getFirstContextBean();
|
||||||
|
System.out.println(JsonUtil.toJsonString(context.getData("f")));
|
||||||
|
Assertions.assertTrue(response.isSuccess());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
/**
|
||||||
|
* <p>Title: liteflow</p>
|
||||||
|
* <p>Description: 轻量级的组件式流程框架</p>
|
||||||
|
* @author Bryan.Zhang
|
||||||
|
* @email weenyc31@163.com
|
||||||
|
* @Date 2020/4/1
|
||||||
|
*/
|
||||||
|
package com.yomahub.liteflow.test.bindData.cmp1;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import com.yomahub.liteflow.core.NodeComponent;
|
||||||
|
import com.yomahub.liteflow.slot.DefaultContext;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@Component("f")
|
||||||
|
public class FCmp extends NodeComponent {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void process() {
|
||||||
|
DefaultContext context = this.getFirstContextBean();
|
||||||
|
Person bindValue = this.getBindData("key", Person.class);
|
||||||
|
if (bindValue != null) {
|
||||||
|
context.setData(this.getNodeId(), bindValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
package com.yomahub.liteflow.test.bindData.cmp1;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
public class Person {
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
private int age;
|
||||||
|
private Date birth1;
|
||||||
|
private LocalDate birth2;
|
||||||
|
private LocalDateTime birth3;
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getAge() {
|
||||||
|
return age;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAge(int age) {
|
||||||
|
this.age = age;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getBirth1() {
|
||||||
|
return birth1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBirth1(Date birth1) {
|
||||||
|
this.birth1 = birth1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LocalDate getBirth2() {
|
||||||
|
return birth2;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBirth2(LocalDate birth2) {
|
||||||
|
this.birth2 = birth2;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LocalDateTime getBirth3() {
|
||||||
|
return birth3;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBirth3(LocalDateTime birth3) {
|
||||||
|
this.birth3 = birth3;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -20,4 +20,9 @@
|
|||||||
<chain id="chain4">
|
<chain id="chain4">
|
||||||
THEN(d, sub.bind("k1", "test2"))
|
THEN(d, sub.bind("k1", "test2"))
|
||||||
</chain>
|
</chain>
|
||||||
|
|
||||||
|
<chain id="chain5">
|
||||||
|
v = "{\"name\":\"jack\", \"age\":19, \"birth1\":\"1990-06-01T12:00:00\", \"birth2\":\"1990-06-01\", \"birth3\":\"1990-06-01T12:00:00\"}";
|
||||||
|
THEN(f.bind("key",v));
|
||||||
|
</chain>
|
||||||
</flow>
|
</flow>
|
||||||
7
pom.xml
7
pom.xml
@@ -39,7 +39,7 @@
|
|||||||
</scm>
|
</scm>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<revision>2.13.0</revision>
|
<revision>2.13.1</revision>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||||
<maven.compiler.source>8</maven.compiler.source>
|
<maven.compiler.source>8</maven.compiler.source>
|
||||||
@@ -136,6 +136,11 @@
|
|||||||
<artifactId>jackson-databind</artifactId>
|
<artifactId>jackson-databind</artifactId>
|
||||||
<version>${jackson.version}</version>
|
<version>${jackson.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.fasterxml.jackson.datatype</groupId>
|
||||||
|
<artifactId>jackson-datatype-jsr310</artifactId>
|
||||||
|
<version>${jackson.version}</version>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.yaml</groupId>
|
<groupId>org.yaml</groupId>
|
||||||
<artifactId>snakeyaml</artifactId>
|
<artifactId>snakeyaml</artifactId>
|
||||||
|
|||||||
Reference in New Issue
Block a user