feat:V3.1.1整合remi-comm到remi-cloud中
This commit is contained in:
@@ -0,0 +1,84 @@
|
||||
package ai.remi.comm.domain.entity;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* @author dianjiu【】
|
||||
* @email dianjiuxyz@gmail.com
|
||||
* @desc BaseEntity
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor(access = AccessLevel.PACKAGE)
|
||||
public class BaseEntity implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 乐观锁
|
||||
*/
|
||||
@Version
|
||||
@TableField("revision")
|
||||
private Integer revision;
|
||||
|
||||
/**
|
||||
* 逻辑删除 (0正常 1删除)
|
||||
* value = "" 默认的原值,默认为 0;
|
||||
* delval = "" 删除后的值,默认为1;
|
||||
*/
|
||||
// @TableLogic(value="0",delval="1")
|
||||
@TableField("deleted")
|
||||
private Integer deleted;
|
||||
|
||||
/**
|
||||
* 部门租户ID
|
||||
*/
|
||||
@TableField("dept_tenant_id")
|
||||
private String deptTenantId;
|
||||
|
||||
/**
|
||||
* 公司租户ID
|
||||
*/
|
||||
@TableField("company_tenant_id")
|
||||
private String companyTenantId;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
@TableField("created_by")
|
||||
private String createdBy;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField(value = "created_at", fill = FieldFill.INSERT)
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime createdAt;
|
||||
|
||||
/**
|
||||
* 更新人
|
||||
*/
|
||||
@TableField("updated_by")
|
||||
private String updatedBy;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@TableField(value = "updated_at", fill = FieldFill.UPDATE)
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime updatedAt;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package ai.remi.comm.domain.entity;
|
||||
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* @author dianjiu【公众号 点九开源】
|
||||
* @email dianjiuxyz@gmail.com
|
||||
* @desc RootEntity
|
||||
*/
|
||||
public interface RootEntity extends Serializable {
|
||||
|
||||
public String getId();
|
||||
|
||||
public RootEntity setId(String id);
|
||||
|
||||
public Integer getRevision();
|
||||
|
||||
public RootEntity setRevision(Integer revision);
|
||||
|
||||
public Integer getDeleted();
|
||||
|
||||
public RootEntity setDeleted(Integer deleted);
|
||||
|
||||
public String getDeptTenantId();
|
||||
|
||||
public RootEntity setDeptTenantId(String deptTenantId);
|
||||
|
||||
public String getCompanyTenantId();
|
||||
|
||||
public RootEntity setCompanyTenantId(String companyTenantId);
|
||||
|
||||
public String getCreatedBy();
|
||||
|
||||
public RootEntity setCreatedBy(String createdBy);
|
||||
|
||||
public LocalDateTime getCreatedAt();
|
||||
|
||||
public RootEntity setCreatedAt(LocalDateTime createdAt);
|
||||
|
||||
public String getUpdatedBy();
|
||||
|
||||
public RootEntity setUpdatedBy(String updatedBy);
|
||||
|
||||
public LocalDateTime getUpdatedAt();
|
||||
|
||||
public RootEntity setUpdatedAt(LocalDateTime updatedAt);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package ai.remi.comm.domain.query;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author dianjiu【公众号 点九开源】
|
||||
* @email dianjiuxyz@gmail.com
|
||||
* @desc PageQuery
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@SuperBuilder(toBuilder = true)
|
||||
public class PageQuery implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 当前页
|
||||
*/
|
||||
@NotBlank(message = "pageNum当前页不能为空")
|
||||
private Integer pageNum;
|
||||
|
||||
/**
|
||||
* 页大小
|
||||
*/
|
||||
@NotBlank(message = "pageSize页大小不能为空")
|
||||
private Integer pageSize;
|
||||
|
||||
/**
|
||||
* 指定排序字段
|
||||
*/
|
||||
private String orderBy;
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
package ai.remi.comm.domain.tree;
|
||||
|
||||
import ai.remi.comm.util.collection.CollectionUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class TreeBuild<T extends TreeNode> {
|
||||
/**
|
||||
* rootId
|
||||
*/
|
||||
public String rootId;
|
||||
/**
|
||||
* 保存参与构建树形的所有数据(通常数据库查询结果)
|
||||
*/
|
||||
public List<T> nodeList = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* 构造方法
|
||||
*
|
||||
* @param nodeList 将数据集合赋值给nodeList,即所有数据作为所有节点。
|
||||
*/
|
||||
public TreeBuild(String rootId, List<T> nodeList) {
|
||||
this.rootId = rootId;
|
||||
this.nodeList = nodeList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取需构建的所有根节点(顶级节点) "0"
|
||||
*
|
||||
* @return 所有根节点List集合
|
||||
*/
|
||||
public List<T> getRootNode() {
|
||||
// 保存所有根节点(所有根节点的数据)
|
||||
List<T> rootNodeList = new ArrayList<>();
|
||||
// treeNode:查询出的每一条数据(节点)
|
||||
for (T treeNode : nodeList) {
|
||||
// 判断当前节点是否为根节点,此处注意:若parentId类型是String,则要采用equals()方法判断。
|
||||
if (this.rootId.equals(treeNode.getParentId())) {
|
||||
// 是,添加
|
||||
rootNodeList.add(treeNode);
|
||||
}
|
||||
}
|
||||
return rootNodeList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据每一个顶级节点(根节点)进行构建树形结构
|
||||
*
|
||||
* @return 构建整棵树
|
||||
*/
|
||||
public List<T> buildTree() {
|
||||
// treeNodes:保存一个顶级节点所构建出来的完整树形
|
||||
List<T> treeNodes = new ArrayList<T>();
|
||||
// getRootNode():获取所有的根节点
|
||||
for (T treeRootNode : getRootNode()) {
|
||||
// 将顶级节点进行构建子树
|
||||
treeRootNode = buildChildTree(treeRootNode);
|
||||
// 完成一个顶级节点所构建的树形,增加进来
|
||||
treeNodes.add(treeRootNode);
|
||||
}
|
||||
// 这里对父节点排序
|
||||
CollectionUtils.sort(treeNodes, "sort");
|
||||
// for循环结束,即获取所有的根节点,树形构建结束,设置树结果
|
||||
return treeNodes;
|
||||
}
|
||||
|
||||
/**
|
||||
* 递归-----构建子树形结构
|
||||
*
|
||||
* @param pNode 根节点(顶级节点)
|
||||
* @return 整棵树
|
||||
*/
|
||||
public T buildChildTree(T pNode) {
|
||||
List<T> childTree = new ArrayList<T>();
|
||||
// nodeList:所有节点集合(所有数据)
|
||||
for (T treeNode : nodeList) {
|
||||
// 判断当前节点的父节点ID是否等于根节点的ID,即当前节点为其下的子节点
|
||||
if (treeNode.getParentId().equals(pNode.getId())) {
|
||||
// 再递归进行判断当前节点的情况,调用自身方法
|
||||
childTree.add(buildChildTree(treeNode));
|
||||
}
|
||||
}
|
||||
// 这里对子节点排序
|
||||
CollectionUtils.sort(childTree, "sort");
|
||||
// for循环结束,即节点下没有任何节点,树形构建结束,设置树结果
|
||||
pNode.setChildren(childTree);
|
||||
return pNode;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package ai.remi.comm.domain.tree;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author dianjiu【公众号 点九开源】
|
||||
* @email dianjiuxyz@gmail.com
|
||||
* @desc ResultBean
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor(access = AccessLevel.PACKAGE)
|
||||
public class TreeNode<T extends TreeNode> implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 8676131899637805509L;
|
||||
|
||||
/**
|
||||
* 当前节点ID
|
||||
*/
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 父节点ID 顶级节点为0
|
||||
*/
|
||||
private String parentId;
|
||||
|
||||
/**
|
||||
* 子节点
|
||||
*/
|
||||
private List<T> children;
|
||||
}
|
||||
Reference in New Issue
Block a user