From 456e1db5a5d37446cebb6f82d45112afbabcc17d Mon Sep 17 00:00:00 2001 From: solo-hx <6gEemAZ> Date: Mon, 19 Aug 2019 17:26:40 +0800 Subject: [PATCH] =?UTF-8?q?dev=E5=88=86=E6=94=AF=20=E5=88=A0=E9=99=A4zTree?= =?UTF-8?q?=E5=B7=A5=E5=85=B7=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/ruoyi/common/utils/tree/Ztree.java | 216 ------------------ .../ruoyi/common/utils/tree/ZtreeUtil.java | 60 ----- 2 files changed, 276 deletions(-) delete mode 100644 ruoyi-common/src/main/java/com/ruoyi/common/utils/tree/Ztree.java delete mode 100644 ruoyi-common/src/main/java/com/ruoyi/common/utils/tree/ZtreeUtil.java diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/tree/Ztree.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/tree/Ztree.java deleted file mode 100644 index b5957d432..000000000 --- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/tree/Ztree.java +++ /dev/null @@ -1,216 +0,0 @@ -package com.ruoyi.common.utils.tree; - -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - * tree结构 - * - * @author solo - * @date 2019/08/16. - */ -public class Ztree { - private String id; - private String text; - private String state; - private boolean isParent; - private boolean checked;; - private int locked; - private List children; - private String iconCls; - private String pid; - private Map attributes = new HashMap(); - private String comment; - private String link; - private String url; - private String target; - private Integer types; - private String code; - private String path; - private Date createtime; - private Date updatetime; - private String object_class; - private String title; - private String name; - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getText() { - return text; - } - - public void setText(String text) { - this.text = text; - } - - public String getState() { - return state; - } - - public void setState(String state) { - this.state = state; - } - - @JsonProperty(value = "isParent") - public boolean getIsParent() { - return isParent; - } - - public void setIsParent(boolean isParent) { - this.isParent = isParent; - } - - public boolean isChecked() { - return checked; - } - - public void setChecked(boolean checked) { - this.checked = checked; - } - - public int getLocked() { - return locked; - } - - public void setLocked(int locked) { - this.locked = locked; - } - - public List getChildren() { - return children; - } - - public void setChildren(List children) { - this.children = children; - } - - public String getIconCls() { - return iconCls; - } - - public void setIconCls(String iconCls) { - this.iconCls = iconCls; - } - - public String getPid() { - return pid; - } - - public void setPid(String pid) { - this.pid = pid; - } - - public Map getAttributes() { - return attributes; - } - - public void setAttributes(Map attributes) { - this.attributes = attributes; - } - - public String getComment() { - return comment; - } - - public void setComment(String comment) { - this.comment = comment; - } - - public String getLink() { - return link; - } - - public void setLink(String link) { - this.link = link; - } - - public String getUrl() { - return url; - } - - public void setUrl(String url) { - this.url = url; - } - - public String getTarget() { - return target; - } - - public void setTarget(String target) { - this.target = target; - } - - public Integer getTypes() { - return types; - } - - public void setTypes(Integer types) { - this.types = types; - } - - public String getCode() { - return code; - } - - public void setCode(String code) { - this.code = code; - } - - public String getPath() { - return path; - } - - public void setPath(String path) { - this.path = path; - } - - public Date getCreatetime() { - return createtime; - } - - public void setCreatetime(Date createtime) { - this.createtime = createtime; - } - - public Date getUpdatetime() { - return updatetime; - } - - public void setUpdatetime(Date updatetime) { - this.updatetime = updatetime; - } - - public String getObject_class() { - return object_class; - } - - public void setObject_class(String object_class) { - this.object_class = object_class; - } - - public String getTitle() { - return title; - } - - public void setTitle(String title) { - this.title = title; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } -} diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/tree/ZtreeUtil.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/tree/ZtreeUtil.java deleted file mode 100644 index 064fa7207..000000000 --- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/tree/ZtreeUtil.java +++ /dev/null @@ -1,60 +0,0 @@ -package com.ruoyi.common.utils.tree; - - -import org.apache.commons.lang3.StringUtils; - -import java.util.ArrayList; -import java.util.List; - -/** - * tree结构工具类 - * - * @author solo - * @date 2019/08/16. - */ -public class ZtreeUtil { - - public static List ztreeList(List list,String pid) { - List returnList = new ArrayList(); - for (Ztree t : list) { - if (StringUtils.equals(t.getPid(), pid)) { - recursionFn(list, t); - returnList.add(t); - } - } - return returnList; - } - - private static void recursionFn(List list, Ztree t) { - List childList = getChildList(list, t);// 得到子节点列表 - t.setChildren(childList); - t.setState("open"); - t.setIsParent(false); - for (Ztree tChild : childList) { - t.setState("closed"); - t.setIsParent(true); - if (hasChild(list, tChild)) {// 判断是否有子节点 - for (Ztree n : childList) { - recursionFn(list, n); - } - } - } - } - - - // 得到子节点列表 - private static List getChildList(List list, Ztree t) { - List tlist = new ArrayList(); - for (Ztree n : list) { - if (StringUtils.equals(n.getPid(), t.getId())) { - tlist.add(n); - } - } - return tlist; - } - - // 判断是否有子节点 - private static boolean hasChild(List list, Ztree t) { - return getChildList(list, t).size() > 0; - } -}