diff --git a/pom.xml b/pom.xml
index 479b308..5266ee6 100644
--- a/pom.xml
+++ b/pom.xml
@@ -5,12 +5,12 @@
top.leafage
leafage-starter-parent
- 0.1.3
+ 0.1.6
leafage-common
- 0.1.8
+ 0.1.9
jar
leafage-common
diff --git a/src/main/java/top/leafage/common/basic/AbstractTreeNodeService.java b/src/main/java/top/leafage/common/basic/AbstractTreeNodeService.java
index a04a8a9..8a3e8f3 100644
--- a/src/main/java/top/leafage/common/basic/AbstractTreeNodeService.java
+++ b/src/main/java/top/leafage/common/basic/AbstractTreeNodeService.java
@@ -3,6 +3,7 @@
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.status.StatusLogger;
+
import java.beans.IntrospectionException;
import java.beans.PropertyDescriptor;
import java.lang.reflect.InvocationTargetException;
@@ -29,20 +30,20 @@ public abstract class AbstractTreeNodeService extends AbstractBasicService {
/**
* 构造 TreeNode 对象
*
- * @param superiorCode superior code
- * @param t 实例数据
- * @param expand 扩展字段
+ * @param t 实例数据
+ * @param expand 扩展字段
* @return TreeNode 对象
* @since 0.1.7
*/
- protected TreeNode construct(Object superiorCode, T t, Set expand) {
+ protected TreeNode construct(T t, Set expand) {
Class> childClass = t.getClass();
Object code = this.getCode(t, childClass);
Object name = this.getName(t, childClass);
+ Object superior = this.getSuperior(t, childClass);
TreeNode treeNode = new TreeNode(Objects.nonNull(code) ? String.valueOf(code) : null,
Objects.nonNull(name) ? String.valueOf(name) : null);
- treeNode.setSuperior(Objects.nonNull(superiorCode) ? String.valueOf(superiorCode) : null);
+ treeNode.setSuperior(Objects.nonNull(superior) ? String.valueOf(superior) : null);
// deal expand
this.expand(treeNode, childClass, t, expand);
diff --git a/src/main/java/top/leafage/common/basic/AbstractVO.java b/src/main/java/top/leafage/common/basic/AbstractVO.java
index 66eb4f1..5aadb68 100644
--- a/src/main/java/top/leafage/common/basic/AbstractVO.java
+++ b/src/main/java/top/leafage/common/basic/AbstractVO.java
@@ -11,31 +11,29 @@
* @author liwenqiang 2020-10-06 22:09
* @since 0.1.6
*/
-public abstract class AbstractVO {
-
- /**
- * 代码
- */
- private C code;
+public abstract class AbstractVO extends BasicVO {
/**
* 修改时间
*/
private LocalDateTime modifyTime;
- public C getCode() {
- return code;
- }
-
- public void setCode(C code) {
- this.code = code;
- }
-
+ /**
+ * modify time getter
+ *
+ * @return modify time
+ */
public LocalDateTime getModifyTime() {
return modifyTime;
}
+ /**
+ * modify time setter
+ *
+ * @param modifyTime modify time
+ */
public void setModifyTime(LocalDateTime modifyTime) {
this.modifyTime = modifyTime;
}
+
}
diff --git a/src/main/java/top/leafage/common/basic/BasicVO.java b/src/main/java/top/leafage/common/basic/BasicVO.java
new file mode 100644
index 0000000..846a802
--- /dev/null
+++ b/src/main/java/top/leafage/common/basic/BasicVO.java
@@ -0,0 +1,57 @@
+package top.leafage.common.basic;
+
+/**
+ * 基础VO类
+ *
+ * @author liwenqiang 2022/7/23 10:04
+ * @since 0.1.9
+ **/
+public class BasicVO {
+
+
+ /**
+ * 代码
+ */
+ private C code;
+
+ /**
+ * 名称
+ */
+ private String name;
+
+ /**
+ * code getter
+ *
+ * @return C
+ */
+ public C getCode() {
+ return code;
+ }
+
+ /**
+ * code setter
+ *
+ * @param code code of model
+ */
+ public void setCode(C code) {
+ this.code = code;
+ }
+
+ /**
+ * name getter
+ *
+ * @return name
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * name setter
+ *
+ * @param name name of model
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+}
diff --git a/src/main/java/top/leafage/common/basic/TreeNode.java b/src/main/java/top/leafage/common/basic/TreeNode.java
index 79dc2b6..8ba9817 100644
--- a/src/main/java/top/leafage/common/basic/TreeNode.java
+++ b/src/main/java/top/leafage/common/basic/TreeNode.java
@@ -1,5 +1,6 @@
package top.leafage.common.basic;
+import java.io.Serial;
import java.io.Serializable;
import java.util.List;
import java.util.Map;
@@ -11,6 +12,7 @@
*/
public class TreeNode implements Serializable {
+ @Serial
private static final long serialVersionUID = 3977470984616592112L;
/**
@@ -29,50 +31,108 @@ public class TreeNode implements Serializable {
* 扩展属性
*/
private Map expand;
-
+ /**
+ * 子节点
+ */
private List children;
+ /**
+ * 构造方法
+ *
+ * @param code code
+ * @param name name
+ */
public TreeNode(String code, String name) {
this.code = code;
this.name = name;
}
+ /**
+ * code getter
+ *
+ * @return code
+ */
public String getCode() {
return code;
}
- public String getName() {
- return name;
- }
-
- public String getSuperior() {
- return superior;
- }
-
- public Map getExpand() {
- return expand;
- }
-
- public List getChildren() {
- return children;
- }
-
+ /**
+ * code setter
+ *
+ * @param code code
+ */
public void setCode(String code) {
this.code = code;
}
+ /**
+ * name getter
+ *
+ * @return name
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * name setter
+ *
+ * @param name name
+ */
public void setName(String name) {
this.name = name;
}
+ /**
+ * superior getter
+ *
+ * @return superior
+ */
+ public String getSuperior() {
+ return superior;
+ }
+
+ /**
+ * superior setter
+ *
+ * @param superior superior
+ */
public void setSuperior(String superior) {
this.superior = superior;
}
+ /**
+ * expand getter
+ *
+ * @return expand
+ */
+ public Map getExpand() {
+ return expand;
+ }
+
+ /**
+ * expand setter
+ *
+ * @param expand expand
+ */
public void setExpand(Map expand) {
this.expand = expand;
}
+ /**
+ * children getter
+ *
+ * @return children
+ */
+ public List getChildren() {
+ return children;
+ }
+
+ /**
+ * children setter
+ *
+ * @param children children
+ */
public void setChildren(List children) {
this.children = children;
}
diff --git a/src/main/java/top/leafage/common/basic/ValidMessage.java b/src/main/java/top/leafage/common/basic/ValidMessage.java
index c52e68e..d840c08 100644
--- a/src/main/java/top/leafage/common/basic/ValidMessage.java
+++ b/src/main/java/top/leafage/common/basic/ValidMessage.java
@@ -1,5 +1,6 @@
package top.leafage.common.basic;
+import java.io.Serial;
import java.io.Serializable;
/**
@@ -10,6 +11,7 @@
**/
public class ValidMessage implements Serializable {
+ @Serial
private static final long serialVersionUID = 3385684846039604779L;
/**
diff --git a/src/main/java/top/leafage/common/reactive/ReactiveAbstractTreeNodeService.java b/src/main/java/top/leafage/common/reactive/ReactiveAbstractTreeNodeService.java
index 6ae1dbe..610b6e3 100644
--- a/src/main/java/top/leafage/common/reactive/ReactiveAbstractTreeNodeService.java
+++ b/src/main/java/top/leafage/common/reactive/ReactiveAbstractTreeNodeService.java
@@ -1,9 +1,15 @@
package top.leafage.common.reactive;
import reactor.core.publisher.Flux;
+import reactor.core.publisher.Mono;
import top.leafage.common.basic.AbstractTreeNodeService;
import top.leafage.common.basic.TreeNode;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
import java.util.Set;
+import java.util.stream.Collectors;
/**
* For reactive to construct tree
@@ -16,36 +22,32 @@ public abstract class ReactiveAbstractTreeNodeService extends AbstractTreeNod
/**
* 处理子节点
*
- * @param superior 上级数据
* @param children 子节点
* @return 树节点数据集
+ * @since 0.1.9
*/
- protected Flux children(T superior, Flux children) {
- return this.children(superior, children, null);
+ protected Flux convert(Flux children) {
+ return this.convert(children, null);
}
/**
* 处理子节点
*
- * @param superior 上级数据
* @param children 子节点
* @param expand 扩展属性
* @return 树节点数据集
+ * @since 0.1.9
*/
- protected Flux children(T superior, Flux children, Set expand) {
- Class> aClass = superior.getClass();
- // ID是集成基础父类的,所以要通过superClass获取
- Object superiorId = this.getId(superior, aClass);
- Object superiorCode = this.getCode(superior, aClass);
-
- return children.filter(child -> this.check(superiorId, child)).flatMap(child -> {
- TreeNode treeNode = this.construct(superiorCode, child, expand);
+ protected Flux convert(Flux children, Set expand) {
+ Flux nodesFlux = children.map(child -> this.construct(child, expand));
+ Mono