From 3ed4d66707d30e685c3401c0abc5be9f90e552a3 Mon Sep 17 00:00:00 2001 From: linbangquan <1437892690@qq.com> Date: Fri, 15 Dec 2023 18:29:21 +0800 Subject: [PATCH] =?UTF-8?q?[=E5=8A=9F=E8=83=BD]=20=E5=90=8E=E7=AB=AF-CMDB-?= =?UTF-8?q?=E6=A8=A1=E5=9E=8B=E8=AF=A6=E6=83=85=E9=A1=B5=E9=9D=A2=E3=80=81?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E9=A1=B9=E6=9F=A5=E8=AF=A2=E7=9A=84=E8=AF=A6?= =?UTF-8?q?=E6=83=85=E9=A1=B5=E9=9D=A2=EF=BC=8C=E5=A2=9E=E5=8A=A0=E6=A0=91?= =?UTF-8?q?=E7=9B=AE=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 关联 #[1047056406249472]后端-CMDB-模型详情页面、配置项查询的详情页面,增加树目录 http://192.168.0.96:8090/demo/rdm.html#/task-detail/939050947543040/939050947543050/1047056406249472 --- .../neatlogic/framework/cmdb/dto/ci/CiVo.java | 10 +++ .../cmdb/dto/cicatalog/CiCatalogNodeVo.java | 85 +++++++++++++++++++ .../cmdb/dto/cicatalog/CiCatalogVo.java | 69 +++++++++++++++ .../cicatalog/CiCatalogIsInUsedException.java | 10 +++ .../CiCatalogNameRepeatException.java | 10 +++ .../cicatalog/CiCatalogNotFoundException.java | 14 +++ 6 files changed, 198 insertions(+) create mode 100644 src/main/java/neatlogic/framework/cmdb/dto/cicatalog/CiCatalogNodeVo.java create mode 100644 src/main/java/neatlogic/framework/cmdb/dto/cicatalog/CiCatalogVo.java create mode 100644 src/main/java/neatlogic/framework/cmdb/exception/cicatalog/CiCatalogIsInUsedException.java create mode 100644 src/main/java/neatlogic/framework/cmdb/exception/cicatalog/CiCatalogNameRepeatException.java create mode 100644 src/main/java/neatlogic/framework/cmdb/exception/cicatalog/CiCatalogNotFoundException.java diff --git a/src/main/java/neatlogic/framework/cmdb/dto/ci/CiVo.java b/src/main/java/neatlogic/framework/cmdb/dto/ci/CiVo.java index 8fb375e..4ff15cf 100644 --- a/src/main/java/neatlogic/framework/cmdb/dto/ci/CiVo.java +++ b/src/main/java/neatlogic/framework/cmdb/dto/ci/CiVo.java @@ -60,6 +60,8 @@ public class CiVo implements Serializable { private Long typeId; @EntityField(name = "类型名称", type = ApiParamType.STRING) private String typeName; + @EntityField(name = "模型目录id", type = ApiParamType.LONG) + private Long catalogId; @EntityField(name = "是否私有模型,0:不是,1:是", type = ApiParamType.INTEGER) private Integer isPrivate; @EntityField(name = "是否在菜单中显示,0:不显示,1:显示", type = ApiParamType.INTEGER) @@ -245,6 +247,14 @@ public class CiVo implements Serializable { this.typeId = typeId; } + public Long getCatalogId() { + return catalogId; + } + + public void setCatalogId(Long catalogId) { + this.catalogId = catalogId; + } + public Integer getIsPrivate() { return isPrivate; } diff --git a/src/main/java/neatlogic/framework/cmdb/dto/cicatalog/CiCatalogNodeVo.java b/src/main/java/neatlogic/framework/cmdb/dto/cicatalog/CiCatalogNodeVo.java new file mode 100644 index 0000000..fb52c76 --- /dev/null +++ b/src/main/java/neatlogic/framework/cmdb/dto/cicatalog/CiCatalogNodeVo.java @@ -0,0 +1,85 @@ +package neatlogic.framework.cmdb.dto.cicatalog; + +import com.alibaba.fastjson.annotation.JSONField; +import neatlogic.framework.common.constvalue.ApiParamType; +import neatlogic.framework.restful.annotation.EntityField; +import org.apache.commons.collections4.CollectionUtils; + +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +public class CiCatalogNodeVo extends CiCatalogVo { + + private static final long serialVersionUID = 9045187703084309760L; + + public static final String CATALOG = "catalog"; + public static final String CI = "ci"; + + @EntityField(name = "common.children", type = ApiParamType.JSONARRAY) + private List children; + + @EntityField(name = "common.childrencount", type = ApiParamType.INTEGER) + private Integer childrenCount; + + @EntityField(name = "common.type", type = ApiParamType.STRING) + private String type; + + @JSONField(serialize=false) + private CiCatalogNodeVo parent; + + public List getChildren() { + if (children == null && Objects.equals(type, CiCatalogNodeVo.CATALOG)) { + children = new ArrayList<>(); + } + return children; + } + + public void setChildren(List children) { + this.children = children; + } + + public Integer getChildrenCount() { + if (childrenCount == null) { + childrenCount = CollectionUtils.size(children); + } + return childrenCount; + } + + public void setChildrenCount(Integer childrenCount) { + this.childrenCount = childrenCount; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public CiCatalogNodeVo getParent() { + return parent; + } + + public void setParent(CiCatalogNodeVo parent) { + this.parent = parent; + } + + public boolean addChild(CiCatalogNodeVo child) { + if (children == null) { + children = new ArrayList<>(); + } + if(children.contains(child)) { + return false; + } + return children.add(child); + } + + public boolean removeChild(CiCatalogNodeVo child) { + if (CollectionUtils.isEmpty(children)) { + return false; + } + return children.remove(child); + } +} diff --git a/src/main/java/neatlogic/framework/cmdb/dto/cicatalog/CiCatalogVo.java b/src/main/java/neatlogic/framework/cmdb/dto/cicatalog/CiCatalogVo.java new file mode 100644 index 0000000..6ca3dd1 --- /dev/null +++ b/src/main/java/neatlogic/framework/cmdb/dto/cicatalog/CiCatalogVo.java @@ -0,0 +1,69 @@ +package neatlogic.framework.cmdb.dto.cicatalog; + +import neatlogic.framework.common.constvalue.ApiParamType; +import neatlogic.framework.restful.annotation.EntityField; +import neatlogic.framework.util.SnowflakeUtil; + +import java.io.Serializable; + +public class CiCatalogVo implements Serializable { + + private static final long serialVersionUID = 9045187703084309759L; + + public static final Long ROOT_PARENTID = -1L; + public static final Long ROOT_ID = 0L; + public static final String ROOT_NAME = "所有"; + @EntityField(name = "common.id", type = ApiParamType.LONG) + private Long id; + @EntityField(name = "common.name", type = ApiParamType.STRING) + private String name; + @EntityField(name = "common.parentid", type = ApiParamType.LONG) + private Long parentId; + @EntityField(name = "common.lft", type = ApiParamType.INTEGER) + private Integer lft; + @EntityField(name = "common.rht", type = ApiParamType.INTEGER) + private Integer rht; + + public Long getId() { + if (id == null) { + id = SnowflakeUtil.uniqueLong(); + } + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Long getParentId() { + return parentId; + } + + public void setParentId(Long parentId) { + this.parentId = parentId; + } + + public Integer getLft() { + return lft; + } + + public void setLft(Integer lft) { + this.lft = lft; + } + + public Integer getRht() { + return rht; + } + + public void setRht(Integer rht) { + this.rht = rht; + } +} diff --git a/src/main/java/neatlogic/framework/cmdb/exception/cicatalog/CiCatalogIsInUsedException.java b/src/main/java/neatlogic/framework/cmdb/exception/cicatalog/CiCatalogIsInUsedException.java new file mode 100644 index 0000000..fbea93c --- /dev/null +++ b/src/main/java/neatlogic/framework/cmdb/exception/cicatalog/CiCatalogIsInUsedException.java @@ -0,0 +1,10 @@ +package neatlogic.framework.cmdb.exception.cicatalog; + +import neatlogic.framework.exception.core.ApiRuntimeException; + +public class CiCatalogIsInUsedException extends ApiRuntimeException { + + public CiCatalogIsInUsedException(String name) { + super("nfcec.cicatalogisinusedexception.cicatalogisinusedexception", name); + } +} diff --git a/src/main/java/neatlogic/framework/cmdb/exception/cicatalog/CiCatalogNameRepeatException.java b/src/main/java/neatlogic/framework/cmdb/exception/cicatalog/CiCatalogNameRepeatException.java new file mode 100644 index 0000000..be696a1 --- /dev/null +++ b/src/main/java/neatlogic/framework/cmdb/exception/cicatalog/CiCatalogNameRepeatException.java @@ -0,0 +1,10 @@ +package neatlogic.framework.cmdb.exception.cicatalog; + +import neatlogic.framework.exception.core.ApiRuntimeException; + +public class CiCatalogNameRepeatException extends ApiRuntimeException { + + public CiCatalogNameRepeatException(String name) { + super("nfcec.cicatalognamerepeatexception.cicatalognamerepeatexception", name); + } +} diff --git a/src/main/java/neatlogic/framework/cmdb/exception/cicatalog/CiCatalogNotFoundException.java b/src/main/java/neatlogic/framework/cmdb/exception/cicatalog/CiCatalogNotFoundException.java new file mode 100644 index 0000000..015421b --- /dev/null +++ b/src/main/java/neatlogic/framework/cmdb/exception/cicatalog/CiCatalogNotFoundException.java @@ -0,0 +1,14 @@ +package neatlogic.framework.cmdb.exception.cicatalog; + +import neatlogic.framework.exception.core.ApiRuntimeException; + +public class CiCatalogNotFoundException extends ApiRuntimeException { + + public CiCatalogNotFoundException(Long id) { + super("nfcec.cicatalognotfoundexception.cicatalognotfoundexception", id); + } + + public CiCatalogNotFoundException(String name) { + super("nfcec.cicatalognotfoundexception.cicatalognotfoundexception", name); + } +} -- Gitee