From 0a09cc73923633f1cb6a88e03894638e2e8ec488 Mon Sep 17 00:00:00 2001 From: linbangquan <1437892690@qq.com> Date: Fri, 15 Dec 2023 18:32:15 +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 --- .../module/cmdb/api/ci/SaveCiApi.java | 1 + .../api/cicatalog/DeleteCiCatalogApi.java | 55 ++++++++ .../cmdb/api/cicatalog/GetCiCatalogApi.java | 51 +++++++ .../ListCiCatalogAndCiForTreeApi.java | 126 ++++++++++++++++++ .../cicatalog/ListCiCatalogForTreeApi.java | 60 +++++++++ .../cmdb/api/cicatalog/MoveCiCatalogApi.java | 76 +++++++++++ .../cmdb/api/cicatalog/SaveCiCatalogApi.java | 81 +++++++++++ .../config/GetResourceEntityApi.java | 2 +- .../config/SaveResourceEntityApi.java | 8 +- .../module/cmdb/dao/mapper/ci/CiMapper.xml | 19 +++ .../dao/mapper/cicatalog/CiCatalogMapper.java | 26 ++++ .../dao/mapper/cicatalog/CiCatalogMapper.xml | 83 ++++++++++++ .../dao/mapper/cientity/CiEntityMapper.xml | 2 +- .../dao/mapper/cischema/CiSchemaMapper.xml | 1 - .../service/cicatalog/CiCatalogService.java | 23 ++++ .../cicatalog/CiCatalogServiceImpl.java | 88 ++++++++++++ .../changelog/2023-12-25/neatlogic_tenant.sql | 15 +++ .../cmdb/changelog/2023-12-25/version.json | 12 ++ .../resources/cmdb/sqlscript/ddl.sql | 16 +++ .../resources/cmdb/sqlscript/dml.sql | 24 ++++ .../resources/cmdb/sqlscript/dmldemo.sql | 11 -- 21 files changed, 762 insertions(+), 18 deletions(-) create mode 100644 src/main/java/neatlogic/module/cmdb/api/cicatalog/DeleteCiCatalogApi.java create mode 100644 src/main/java/neatlogic/module/cmdb/api/cicatalog/GetCiCatalogApi.java create mode 100644 src/main/java/neatlogic/module/cmdb/api/cicatalog/ListCiCatalogAndCiForTreeApi.java create mode 100644 src/main/java/neatlogic/module/cmdb/api/cicatalog/ListCiCatalogForTreeApi.java create mode 100644 src/main/java/neatlogic/module/cmdb/api/cicatalog/MoveCiCatalogApi.java create mode 100644 src/main/java/neatlogic/module/cmdb/api/cicatalog/SaveCiCatalogApi.java create mode 100644 src/main/java/neatlogic/module/cmdb/dao/mapper/cicatalog/CiCatalogMapper.java create mode 100644 src/main/java/neatlogic/module/cmdb/dao/mapper/cicatalog/CiCatalogMapper.xml create mode 100644 src/main/java/neatlogic/module/cmdb/service/cicatalog/CiCatalogService.java create mode 100644 src/main/java/neatlogic/module/cmdb/service/cicatalog/CiCatalogServiceImpl.java create mode 100644 src/main/resources/neatlogic/resources/cmdb/changelog/2023-12-25/neatlogic_tenant.sql create mode 100644 src/main/resources/neatlogic/resources/cmdb/changelog/2023-12-25/version.json diff --git a/src/main/java/neatlogic/module/cmdb/api/ci/SaveCiApi.java b/src/main/java/neatlogic/module/cmdb/api/ci/SaveCiApi.java index 969f50ef..8b3b168a 100644 --- a/src/main/java/neatlogic/module/cmdb/api/ci/SaveCiApi.java +++ b/src/main/java/neatlogic/module/cmdb/api/ci/SaveCiApi.java @@ -74,6 +74,7 @@ public class SaveCiApi extends PrivateApiComponentBase { @Param(name = "description", type = ApiParamType.STRING, desc = "common.memo", maxLength = 500, xss = true), @Param(name = "icon", type = ApiParamType.STRING, isRequired = true, desc = "common.icon"), @Param(name = "typeId", type = ApiParamType.LONG, desc = "common.typeid", isRequired = true), + @Param(name = "catalogId", type = ApiParamType.LONG, desc = "common.catalogid", isRequired = true), @Param(name = "parentCiId", type = ApiParamType.LONG, desc = "term.cmdb.parentcientityid"), @Param(name = "fileId", type = ApiParamType.LONG, desc = "term.cmdb.virtualcifileid"), @Param(name = "expiredDay", type = ApiParamType.INTEGER, desc = "common.expireddays"), diff --git a/src/main/java/neatlogic/module/cmdb/api/cicatalog/DeleteCiCatalogApi.java b/src/main/java/neatlogic/module/cmdb/api/cicatalog/DeleteCiCatalogApi.java new file mode 100644 index 00000000..1bc64c69 --- /dev/null +++ b/src/main/java/neatlogic/module/cmdb/api/cicatalog/DeleteCiCatalogApi.java @@ -0,0 +1,55 @@ +package neatlogic.module.cmdb.api.cicatalog; + +import com.alibaba.fastjson.JSONObject; +import neatlogic.framework.auth.core.AuthAction; +import neatlogic.framework.cmdb.auth.label.CMDB_BASE; +import neatlogic.framework.cmdb.dto.cicatalog.CiCatalogVo; +import neatlogic.framework.cmdb.exception.cicatalog.CiCatalogIsInUsedException; +import neatlogic.framework.cmdb.exception.cicatalog.CiCatalogNotFoundException; +import neatlogic.framework.common.constvalue.ApiParamType; +import neatlogic.framework.restful.annotation.*; +import neatlogic.framework.restful.constvalue.OperationTypeEnum; +import neatlogic.framework.restful.core.privateapi.PrivateApiComponentBase; +import neatlogic.module.cmdb.service.cicatalog.CiCatalogService; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; + +@Service +@AuthAction(action = CMDB_BASE.class) +@OperationType(type = OperationTypeEnum.SEARCH) +public class DeleteCiCatalogApi extends PrivateApiComponentBase { + + @Resource + private CiCatalogService ciCatalogService; + + @Override + public String getName() { + return "nmcac.deletecicatalogapi.getname"; + } + + @Input({ + @Param(name = "id", type = ApiParamType.LONG, isRequired = true, desc = "common.id") + }) + @Output({}) + @Description(desc = "nmcac.deletecicatalogapi.getname") + @Override + public Object myDoService(JSONObject paramObj) throws Exception { + Long id = paramObj.getLong("id"); + CiCatalogVo ciCatalog = ciCatalogService.getCiCatalog(id); + if (ciCatalog == null) { + throw new CiCatalogNotFoundException(id); + } + int count = ciCatalogService.checkCiCatalogIsInUsed(id); + if (count > 0) { + throw new CiCatalogIsInUsedException(ciCatalog.getName()); + } + ciCatalogService.deleteCiCatalog(id); + return null; + } + + @Override + public String getToken() { + return "cmdb/cicatalog/delete"; + } +} diff --git a/src/main/java/neatlogic/module/cmdb/api/cicatalog/GetCiCatalogApi.java b/src/main/java/neatlogic/module/cmdb/api/cicatalog/GetCiCatalogApi.java new file mode 100644 index 00000000..c48f8fc9 --- /dev/null +++ b/src/main/java/neatlogic/module/cmdb/api/cicatalog/GetCiCatalogApi.java @@ -0,0 +1,51 @@ +package neatlogic.module.cmdb.api.cicatalog; + +import com.alibaba.fastjson.JSONObject; +import neatlogic.framework.auth.core.AuthAction; +import neatlogic.framework.cmdb.auth.label.CMDB_BASE; +import neatlogic.framework.cmdb.dto.cicatalog.CiCatalogVo; +import neatlogic.framework.cmdb.exception.cicatalog.CiCatalogNotFoundException; +import neatlogic.framework.common.constvalue.ApiParamType; +import neatlogic.framework.restful.annotation.*; +import neatlogic.framework.restful.constvalue.OperationTypeEnum; +import neatlogic.framework.restful.core.privateapi.PrivateApiComponentBase; +import neatlogic.module.cmdb.service.cicatalog.CiCatalogService; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; + +@Service +@AuthAction(action = CMDB_BASE.class) +@OperationType(type = OperationTypeEnum.SEARCH) +public class GetCiCatalogApi extends PrivateApiComponentBase { + + @Resource + private CiCatalogService ciCatalogService; + + @Override + public String getName() { + return "nmcac.getcicatalogapi.getname"; + } + + @Input({ + @Param(name = "id", type = ApiParamType.LONG, isRequired = true, desc = "common.id") + }) + @Output({ + @Param(explode = CiCatalogVo.class) + }) + @Description(desc = "nmcac.getcicatalogapi.getname") + @Override + public Object myDoService(JSONObject paramObj) throws Exception { + Long id = paramObj.getLong("id"); + CiCatalogVo ciCatalog = ciCatalogService.getCiCatalog(id); + if (ciCatalog == null) { + throw new CiCatalogNotFoundException(id); + } + return ciCatalog; + } + + @Override + public String getToken() { + return "cmdb/cicatalog/get"; + } +} diff --git a/src/main/java/neatlogic/module/cmdb/api/cicatalog/ListCiCatalogAndCiForTreeApi.java b/src/main/java/neatlogic/module/cmdb/api/cicatalog/ListCiCatalogAndCiForTreeApi.java new file mode 100644 index 00000000..3a02dbec --- /dev/null +++ b/src/main/java/neatlogic/module/cmdb/api/cicatalog/ListCiCatalogAndCiForTreeApi.java @@ -0,0 +1,126 @@ +package neatlogic.module.cmdb.api.cicatalog; + +import com.alibaba.fastjson.JSONObject; +import neatlogic.framework.auth.core.AuthAction; +import neatlogic.framework.cmdb.auth.label.CMDB_BASE; +import neatlogic.framework.cmdb.dto.ci.CiVo; +import neatlogic.framework.cmdb.dto.cicatalog.CiCatalogNodeVo; +import neatlogic.framework.cmdb.dto.cicatalog.CiCatalogVo; +import neatlogic.framework.common.constvalue.ApiParamType; +import neatlogic.framework.restful.annotation.*; +import neatlogic.framework.restful.constvalue.OperationTypeEnum; +import neatlogic.framework.restful.core.privateapi.PrivateApiComponentBase; +import neatlogic.module.cmdb.dao.mapper.ci.CiMapper; +import neatlogic.module.cmdb.service.cicatalog.CiCatalogService; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@Service +@AuthAction(action = CMDB_BASE.class) +@OperationType(type = OperationTypeEnum.SEARCH) +public class ListCiCatalogAndCiForTreeApi extends PrivateApiComponentBase { + + @Resource + private CiMapper ciMapper; + + @Resource + private CiCatalogService ciCatalogService; + + @Override + public String getName() { + return "nmcac.listcicatalogandcifortreeapi.getname"; + } + + @Input({ + @Param(name = "keyword", type = ApiParamType.STRING, xss = true, desc = "common.keyword") + }) + @Output({ + @Param(name = "tbodyList", explode = CiCatalogVo[].class, desc = "common.tbodylist") + }) + @Description(desc = "nmcac.listcicatalogandcifortreeapi.getname") + @Override + public Object myDoService(JSONObject paramObj) throws Exception { + String keyword = paramObj.getString("keyword"); + if (StringUtils.isNotBlank(keyword)) { + keyword = keyword.toLowerCase(); + } + List allNodeList = ciCatalogService.getAllCiCatalogList(); + if (CollectionUtils.isEmpty(allNodeList)) { + return allNodeList; + } + CiCatalogNodeVo rootNode = allNodeList.get(0); + Map id2NodeMap = new HashMap<>(); + List matchKeywordCiCatalogNodeList = new ArrayList<>(); + for (CiCatalogNodeVo node : allNodeList) { + id2NodeMap.put(node.getId(), node); + if (StringUtils.isNotBlank(keyword)) { + if (node.getName().toLowerCase().contains(keyword)) { + matchKeywordCiCatalogNodeList.add(node); + } + } + } + List ciNodeList = new ArrayList<>(); + List ciList = ciMapper.getAllCi(null); + for (CiVo ciVo : ciList) { + if (StringUtils.isNotBlank(keyword)) { + if (!ciVo.getName().toLowerCase().contains(keyword) && !ciVo.getLabel().toLowerCase().contains(keyword)) { + continue; + } + } + if (ciVo.getCatalogId() == null) { + continue; + } + CiCatalogNodeVo node = id2NodeMap.get(ciVo.getCatalogId()); + if (node == null) { + continue; + } + if (StringUtils.isNotBlank(keyword)) { + matchKeywordCiCatalogNodeList.add(node); + } + CiCatalogNodeVo ciNode = new CiCatalogNodeVo(); + ciNode.setId(ciVo.getId()); + ciNode.setName(ciVo.getLabel() + "(" + ciVo.getName() + ")"); + ciNode.setParentId(ciVo.getCatalogId()); + ciNode.setType(CiCatalogNodeVo.CI); + ciNodeList.add(ciNode); + } + List catalogList = new ArrayList<>(); + for (CiCatalogNodeVo node : allNodeList) { + node.setType(CiCatalogNodeVo.CATALOG); + if (CollectionUtils.isNotEmpty(matchKeywordCiCatalogNodeList)) { + for (CiCatalogNodeVo matchKeywordCiCatalogNode : matchKeywordCiCatalogNodeList) { + if (node.getLft() <= matchKeywordCiCatalogNode.getLft() && node.getRht() >= matchKeywordCiCatalogNode.getRht()) { + catalogList.add(node); + } + } + } else { + catalogList.add(node); + } + } + for (CiCatalogNodeVo node : catalogList) { + CiCatalogNodeVo parent = id2NodeMap.get(node.getParentId()); + if (parent != null) { + parent.addChild(node); + } + } + for (CiCatalogNodeVo node : ciNodeList) { + CiCatalogNodeVo parent = id2NodeMap.get(node.getParentId()); + if (parent != null) { + parent.addChild(node); + } + } + return rootNode.getChildren(); + } + + @Override + public String getToken() { + return "cmdb/cicatalogandci/listtree"; + } +} diff --git a/src/main/java/neatlogic/module/cmdb/api/cicatalog/ListCiCatalogForTreeApi.java b/src/main/java/neatlogic/module/cmdb/api/cicatalog/ListCiCatalogForTreeApi.java new file mode 100644 index 00000000..5c5b424f --- /dev/null +++ b/src/main/java/neatlogic/module/cmdb/api/cicatalog/ListCiCatalogForTreeApi.java @@ -0,0 +1,60 @@ +package neatlogic.module.cmdb.api.cicatalog; + +import com.alibaba.fastjson.JSONObject; +import neatlogic.framework.auth.core.AuthAction; +import neatlogic.framework.cmdb.auth.label.CMDB_BASE; +import neatlogic.framework.cmdb.dto.cicatalog.CiCatalogNodeVo; +import neatlogic.framework.cmdb.dto.cicatalog.CiCatalogVo; +import neatlogic.framework.restful.annotation.*; +import neatlogic.framework.restful.constvalue.OperationTypeEnum; +import neatlogic.framework.restful.core.privateapi.PrivateApiComponentBase; +import neatlogic.module.cmdb.service.cicatalog.CiCatalogService; +import org.apache.commons.collections4.CollectionUtils; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +@Service +@AuthAction(action = CMDB_BASE.class) +@OperationType(type = OperationTypeEnum.SEARCH) +public class ListCiCatalogForTreeApi extends PrivateApiComponentBase { + + @Resource + private CiCatalogService ciCatalogService; + + @Override + public String getName() { + return "nmcac.listcicatalogfortreeapi.getname"; + } + + @Input({}) + @Output({ + @Param(name = "tbodyList", explode = CiCatalogVo[].class, desc = "common.tbodylist") + }) + @Description(desc = "nmcac.listcicatalogfortreeapi.getname") + @Override + public Object myDoService(JSONObject paramObj) throws Exception { + List allNodeList = ciCatalogService.getAllCiCatalogList(); + if (CollectionUtils.isEmpty(allNodeList)) { + return allNodeList; + } + CiCatalogNodeVo rootNode = allNodeList.get(0); + Map id2NodeMap = allNodeList.stream().collect(Collectors.toMap(e -> e.getId(), e -> e)); + for (CiCatalogNodeVo node : allNodeList) { + node.setType(CiCatalogNodeVo.CATALOG); + CiCatalogNodeVo parent = id2NodeMap.get(node.getParentId()); + if (parent != null) { + parent.addChild(node); + } + } + return rootNode.getChildren(); + } + + @Override + public String getToken() { + return "cmdb/cicatalog/listtree"; + } +} diff --git a/src/main/java/neatlogic/module/cmdb/api/cicatalog/MoveCiCatalogApi.java b/src/main/java/neatlogic/module/cmdb/api/cicatalog/MoveCiCatalogApi.java new file mode 100644 index 00000000..d6f84f36 --- /dev/null +++ b/src/main/java/neatlogic/module/cmdb/api/cicatalog/MoveCiCatalogApi.java @@ -0,0 +1,76 @@ +package neatlogic.module.cmdb.api.cicatalog; + +import com.alibaba.fastjson.JSONObject; +import neatlogic.framework.auth.core.AuthAction; +import neatlogic.framework.cmdb.auth.label.CMDB_BASE; +import neatlogic.framework.cmdb.dto.cicatalog.CiCatalogVo; +import neatlogic.framework.cmdb.exception.cicatalog.CiCatalogNotFoundException; +import neatlogic.framework.cmdb.exception.cicatalog.CiCatalogNameRepeatException; +import neatlogic.framework.common.constvalue.ApiParamType; +import neatlogic.framework.lrcode.LRCodeManager; +import neatlogic.framework.lrcode.constvalue.MoveType; +import neatlogic.framework.lrcode.exception.MoveTargetNodeIllegalException; +import neatlogic.framework.restful.annotation.Description; +import neatlogic.framework.restful.annotation.Input; +import neatlogic.framework.restful.annotation.OperationType; +import neatlogic.framework.restful.annotation.Param; +import neatlogic.framework.restful.constvalue.OperationTypeEnum; +import neatlogic.framework.restful.core.privateapi.PrivateApiComponentBase; +import neatlogic.module.cmdb.service.cicatalog.CiCatalogService; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import javax.annotation.Resource; + +@Service +@Transactional +@AuthAction(action = CMDB_BASE.class) +@OperationType(type = OperationTypeEnum.UPDATE) +public class MoveCiCatalogApi extends PrivateApiComponentBase { + + @Resource + private CiCatalogService ciCatalogService; + + @Override + public String getName() { + return "nmcac.movecicatalogapi.getname"; + } + + @Input({ + @Param(name = "id", type = ApiParamType.STRING, isRequired = true, desc = "common.id"), + @Param(name = "targetId", type = ApiParamType.STRING, isRequired = true, desc = "common.targetid"), + @Param(name = "moveType", type = ApiParamType.ENUM, rule = "inner,prev,next", isRequired = true, desc = "common.type") + }) + @Description(desc = "nmcac.movecicatalogapi.getname") + @Override + public Object myDoService(JSONObject paramObj) throws Exception { + Long id = paramObj.getLong("id"); + Long targetId = paramObj.getLong("targetId"); + String moveType = paramObj.getString("moveType"); + + if (id.equals(targetId)) { + throw new MoveTargetNodeIllegalException(); + } + CiCatalogVo moveCiCatalog = ciCatalogService.getCiCatalog(id); + if (moveCiCatalog == null) { + throw new CiCatalogNotFoundException(id); + } + if (!targetId.equals(CiCatalogVo.ROOT_ID)) { + CiCatalogVo targetCiCatalog = ciCatalogService.getCiCatalog(targetId); + if (targetCiCatalog == null) { + throw new CiCatalogNotFoundException(targetId); + } + } + LRCodeManager.moveTreeNode("cmdb_ci_catalog", "id", "parent_id", id, MoveType.getMoveType(moveType), targetId); + moveCiCatalog.setParentId(targetId); + if (ciCatalogService.checkCiCatalogNameIsRepeat(moveCiCatalog) > 0) { + throw new CiCatalogNameRepeatException(moveCiCatalog.getName()); + } + return null; + } + + @Override + public String getToken() { + return "cmdb/cicatalog/move"; + } +} diff --git a/src/main/java/neatlogic/module/cmdb/api/cicatalog/SaveCiCatalogApi.java b/src/main/java/neatlogic/module/cmdb/api/cicatalog/SaveCiCatalogApi.java new file mode 100644 index 00000000..3353de9f --- /dev/null +++ b/src/main/java/neatlogic/module/cmdb/api/cicatalog/SaveCiCatalogApi.java @@ -0,0 +1,81 @@ +package neatlogic.module.cmdb.api.cicatalog; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import neatlogic.framework.auth.core.AuthAction; +import neatlogic.framework.autoexec.exception.AutoexecCatalogRepeatException; +import neatlogic.framework.cmdb.auth.label.CMDB_BASE; +import neatlogic.framework.cmdb.dto.cicatalog.CiCatalogVo; +import neatlogic.framework.cmdb.exception.cicatalog.CiCatalogNotFoundException; +import neatlogic.framework.cmdb.exception.cicatalog.CiCatalogNameRepeatException; +import neatlogic.framework.common.constvalue.ApiParamType; +import neatlogic.framework.dto.FieldValidResultVo; +import neatlogic.framework.restful.annotation.*; +import neatlogic.framework.restful.constvalue.OperationTypeEnum; +import neatlogic.framework.restful.core.IValid; +import neatlogic.framework.restful.core.privateapi.PrivateApiComponentBase; +import neatlogic.framework.util.RegexUtils; +import neatlogic.module.cmdb.service.cicatalog.CiCatalogService; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import javax.annotation.Resource; + +@Service +@Transactional +@AuthAction(action = CMDB_BASE.class) +@OperationType(type = OperationTypeEnum.UPDATE) +public class SaveCiCatalogApi extends PrivateApiComponentBase { + + @Resource + private CiCatalogService ciCatalogService; + + @Override + public String getName() { + return "nmcac.savecicatalogapi.getname"; + } + + @Input({ + @Param(name = "id", type = ApiParamType.LONG, desc = "common.id"), + @Param(name = "name", type = ApiParamType.REGEX, rule = RegexUtils.NAME, desc = "common.name", maxLength = 50, isRequired = true, xss = true), + @Param(name = "parentId", type = ApiParamType.LONG, desc = "common.parentid"), + }) + @Output({@Param(name = "id", type = ApiParamType.LONG, desc = "common.id")}) + @Description(desc = "nmcac.savecicatalogapi.getname") + @Override + public Object myDoService(JSONObject paramObj) throws Exception { + CiCatalogVo ciCatalog = paramObj.toJavaObject(CiCatalogVo.class); + if (ciCatalog.getParentId() == null) { + ciCatalog.setParentId(CiCatalogVo.ROOT_ID); + } + // 同级下不重复 + if (ciCatalogService.checkCiCatalogNameIsRepeat(ciCatalog) > 0) { + throw new CiCatalogNameRepeatException(ciCatalog.getName()); + } + Long id = paramObj.getLong("id"); + if (id != null) { + if (ciCatalogService.checkCiCatalogIsExists(id) == 0) { + throw new CiCatalogNotFoundException(id); + } + } + return ciCatalogService.saveCiCatalog(ciCatalog); + } + + @Override + public String getToken() { + return "cmdb/cicatalog/save"; + } + + public IValid name() { + return value -> { + CiCatalogVo vo = JSON.toJavaObject(value, CiCatalogVo.class); + if (vo.getParentId() == null) { + vo.setParentId(CiCatalogVo.ROOT_ID); + } + if (ciCatalogService.checkCiCatalogNameIsRepeat(vo) > 0) { + return new FieldValidResultVo(new AutoexecCatalogRepeatException(vo.getName())); + } + return new FieldValidResultVo(); + }; + } +} diff --git a/src/main/java/neatlogic/module/cmdb/api/resourcecenter/config/GetResourceEntityApi.java b/src/main/java/neatlogic/module/cmdb/api/resourcecenter/config/GetResourceEntityApi.java index 4ba92175..8f177bd3 100644 --- a/src/main/java/neatlogic/module/cmdb/api/resourcecenter/config/GetResourceEntityApi.java +++ b/src/main/java/neatlogic/module/cmdb/api/resourcecenter/config/GetResourceEntityApi.java @@ -82,13 +82,13 @@ public class GetResourceEntityApi extends PrivateApiComponentBase { if (resourceEntityVo == null) { resourceEntityVo = new ResourceEntityVo(); resourceEntityVo.setName(sceneEntityVo.getName()); - resourceEntityVo.setLabel(sceneEntityVo.getLabel()); } else if (resourceEntityVo.getCiId() != null) { CiVo ciVo = ciMapper.getCiById(resourceEntityVo.getCiId()); if (ciVo != null) { resourceEntityVo.setCi(ciVo); } } + resourceEntityVo.setLabel(sceneEntityVo.getLabel()); resourceEntityVo.setDescription(sceneEntityVo.getDescription()); List fieldList = ResourceEntityFactory.getFieldListByViewName(name); resourceEntityVo.setFieldList(fieldList); diff --git a/src/main/java/neatlogic/module/cmdb/api/resourcecenter/config/SaveResourceEntityApi.java b/src/main/java/neatlogic/module/cmdb/api/resourcecenter/config/SaveResourceEntityApi.java index 40579e56..778165b5 100644 --- a/src/main/java/neatlogic/module/cmdb/api/resourcecenter/config/SaveResourceEntityApi.java +++ b/src/main/java/neatlogic/module/cmdb/api/resourcecenter/config/SaveResourceEntityApi.java @@ -74,7 +74,7 @@ public class SaveResourceEntityApi extends PrivateApiComponentBase { @Input({ @Param(name = "name", type = ApiParamType.STRING, isRequired = true, desc = "common.name"), @Param(name = "label", type = ApiParamType.STRING, isRequired = true, desc = "common.cnname"), - @Param(name = "config", type = ApiParamType.JSONOBJECT, isRequired = true, desc = "配置"), + @Param(name = "config", type = ApiParamType.JSONOBJECT, isRequired = true, desc = "common.config"), @Param(name = "description", type = ApiParamType.STRING, desc = "common.description") }) @Description(desc = "nmcarc.saveresourceentityapi.getname") @@ -93,13 +93,13 @@ public class SaveResourceEntityApi extends PrivateApiComponentBase { resourceEntityVo.setCiId(mainCiVo.getId()); } } + resourceEntityVo.setDescription(sceneEntityVo.getDescription()); + resourceEntityVo.setLabel(sceneEntityVo.getLabel()); boolean configEquals = false; ResourceEntityVo oldResourceEntityVo = resourceEntityMapper.getResourceEntityByName(resourceEntityVo.getName()); if (oldResourceEntityVo != null) { - boolean labelEquals = Objects.equals(resourceEntityVo.getLabel(), oldResourceEntityVo.getLabel()); - boolean descriptionEquals = Objects.equals(resourceEntityVo.getDescription(), oldResourceEntityVo.getDescription()); configEquals = Objects.equals(resourceEntityVo.getConfigStr(), oldResourceEntityVo.getConfigStr()); - if (labelEquals && descriptionEquals && configEquals) { + if (configEquals) { return null; } resourceEntityMapper.updateResourceEntityLabelAndDescription(resourceEntityVo); diff --git a/src/main/java/neatlogic/module/cmdb/dao/mapper/ci/CiMapper.xml b/src/main/java/neatlogic/module/cmdb/dao/mapper/ci/CiMapper.xml index 882b7a10..3e5ddc0d 100644 --- a/src/main/java/neatlogic/module/cmdb/dao/mapper/ci/CiMapper.xml +++ b/src/main/java/neatlogic/module/cmdb/dao/mapper/ci/CiMapper.xml @@ -70,6 +70,7 @@ a.`description`, a.`icon`, a.`type_id` AS typeId, + a.`catalog_id` AS catalogId, a.`is_private` AS isPrivate, a.`is_menu` AS isMenu, a.`parent_ci_id` AS parentCiId, @@ -92,6 +93,7 @@ a.`icon`, a.`parent_ci_id` AS parentCiId, a.`type_id` AS typeId, + a.`catalog_id` AS catalogId, a.`is_private` AS isPrivate, a.`is_menu` AS isMenu, a.`is_abstract` AS isAbstract, @@ -136,6 +138,7 @@ a.`icon`, a.`parent_ci_id` AS parentCiId, a.`type_id` AS typeId, + a.`catalog_id` AS catalogId, a.`is_private` AS isPrivate, a.`is_menu` AS isMenu, a.`is_abstract` AS isAbstract, @@ -190,6 +193,7 @@ a.`icon`, a.`parent_ci_id` AS parentCiId, a.`type_id` AS typeId, + a.`catalog_id` AS catalogId, a.`is_private` AS isPrivate, a.`is_menu` AS isMenu, a.`is_abstract` AS isAbstract, @@ -212,6 +216,7 @@ a.`icon`, a.`parent_ci_id` AS parentCiId, a.`type_id` AS typeId, + a.`catalog_id` AS catalogId, a.`is_private` AS isPrivate, a.`is_menu` AS isMenu, a.`is_abstract` AS isAbstract, @@ -309,6 +314,7 @@ a.`description`, a.`icon`, a.`type_id` AS typeId, + a.`catalog_id` AS catalogId, a.`is_private` AS isPrivate, a.`is_menu` AS isMenu, a.`parent_ci_id` AS parentCiId, @@ -328,6 +334,7 @@ a.`description`, a.`icon`, a.`type_id` AS typeId, + a.`catalog_id` AS catalogId, a.`is_private` AS isPrivate, a.`is_menu` AS isMenu, a.`parent_ci_id` AS parentCiId, @@ -347,6 +354,7 @@ a.`description`, a.`icon`, a.`type_id` AS typeId, + a.`catalog_id` AS catalogId, a.`is_private` AS isPrivate, a.`is_menu` AS isMenu, a.`parent_ci_id` AS parentCiId, @@ -415,6 +423,7 @@ b.`is_private` AS isPrivate, b.`is_menu` AS ciIsMenu, b.`type_id` AS typeId, + b.`catalog_id` AS catalogId, b.`parent_ci_id` AS parentCiId, d.`name` AS parentCiName, d.`icon` AS parentCiIcon, @@ -470,6 +479,7 @@ `is_private` AS isPrivate, `is_menu` AS ciIsMenu, `type_id` AS typeId, + `catalog_id` AS catalogId, `parent_ci_id` AS parentCiId, `is_abstract` AS isAbstract, `is_virtual` AS isVirtual, @@ -492,6 +502,7 @@ `lft`, `rht`, `type_id` AS typeId, + `catalog_id` AS catalogId, `is_private` AS isPrivate, `is_menu` AS isMenu, `is_abstract` AS isAbstract, @@ -511,6 +522,7 @@ + @@ -537,6 +549,7 @@ a.`description`, a.`icon`, a.`type_id` AS typeId, + a.`catalog_id` AS catalogId, d.`name` AS typeName, a.`is_private` AS isPrivate, a.`is_menu` AS isMenu, @@ -566,6 +579,7 @@ a.`description`, a.`icon`, a.`type_id` AS typeId, + a.`catalog_id` AS catalogId, d.`name` AS typeName, a.`is_private` AS isPrivate, a.`is_menu` AS isMenu, @@ -594,6 +608,7 @@ a.`description`, a.`icon`, a.`type_id` AS typeId, + a.`catalog_id` AS catalogId, d.`name` AS typeName, a.`is_private` AS isPrivate, a.`is_menu` AS isMenu, @@ -628,6 +643,7 @@ `description`, `icon`, `type_id` AS typeId, + `catalog_id` AS catalogId, `parent_ci_id` AS parentCiId, `name_attr_id` AS nameAttrId, `lft`, @@ -658,6 +674,7 @@ `description` = #{description}, `icon` = #{icon}, `type_id` = #{typeId}, + `catalog_id` = #{catalogId}, `is_private` = #{isPrivate}, `is_menu` = #{isMenu}, `parent_ci_id` = #{parentCiId}, @@ -676,6 +693,7 @@ `description`, `icon`, `type_id`, + `catalog_id`, `is_private`, `is_menu`, `is_abstract`, @@ -693,6 +711,7 @@ #{description}, #{icon}, #{typeId}, + #{catalogId}, #{isPrivate}, #{isMenu}, #{isAbstract}, diff --git a/src/main/java/neatlogic/module/cmdb/dao/mapper/cicatalog/CiCatalogMapper.java b/src/main/java/neatlogic/module/cmdb/dao/mapper/cicatalog/CiCatalogMapper.java new file mode 100644 index 00000000..b8153fbe --- /dev/null +++ b/src/main/java/neatlogic/module/cmdb/dao/mapper/cicatalog/CiCatalogMapper.java @@ -0,0 +1,26 @@ +package neatlogic.module.cmdb.dao.mapper.cicatalog; + +import neatlogic.framework.cmdb.dto.cicatalog.CiCatalogNodeVo; +import neatlogic.framework.cmdb.dto.cicatalog.CiCatalogVo; +import neatlogic.framework.common.dto.BasePageVo; + +import java.util.List; + +public interface CiCatalogMapper { + + int checkCiCatalogIsExists(Long id); + + int checkCiCatalogNameIsRepeat(CiCatalogVo ciCatalog); + + CiCatalogVo getCiCatalogById(Long id); + + int getAllCount(); + + List getCiCatalogList(BasePageVo searchVo); + + int checkCiCatalogIsInUsed(Long id); + + Long insertCiCatalog(CiCatalogVo ciCatalog); + + void deleteCiCatalog(Long id); +} diff --git a/src/main/java/neatlogic/module/cmdb/dao/mapper/cicatalog/CiCatalogMapper.xml b/src/main/java/neatlogic/module/cmdb/dao/mapper/cicatalog/CiCatalogMapper.xml new file mode 100644 index 00000000..a551cca3 --- /dev/null +++ b/src/main/java/neatlogic/module/cmdb/dao/mapper/cicatalog/CiCatalogMapper.xml @@ -0,0 +1,83 @@ + + + + + + + + + + + + + + + + + + + + INSERT INTO `cmdb_ci_catalog` ( + `id`, + `name`, + `parent_id`, + `lft`, + `rht` + ) + VALUES + ( + #{id}, + #{name}, + #{parentId}, + #{lft}, + #{rht} + ) + ON DUPLICATE KEY UPDATE + `name` = #{name} + + + + DELETE FROM `cmdb_ci_catalog` WHERE `id` = #{value} + + diff --git a/src/main/java/neatlogic/module/cmdb/dao/mapper/cientity/CiEntityMapper.xml b/src/main/java/neatlogic/module/cmdb/dao/mapper/cientity/CiEntityMapper.xml index 424d3f6a..3ee90c3d 100644 --- a/src/main/java/neatlogic/module/cmdb/dao/mapper/cientity/CiEntityMapper.xml +++ b/src/main/java/neatlogic/module/cmdb/dao/mapper/cientity/CiEntityMapper.xml @@ -1225,7 +1225,7 @@ - INSERT INTO ${ciTableName} ( + INSERT ignore INTO ${ciTableName} ( `${attr.attrId}`, diff --git a/src/main/java/neatlogic/module/cmdb/dao/mapper/cischema/CiSchemaMapper.xml b/src/main/java/neatlogic/module/cmdb/dao/mapper/cischema/CiSchemaMapper.xml index 83fc82c3..cf1da96b 100644 --- a/src/main/java/neatlogic/module/cmdb/dao/mapper/cischema/CiSchemaMapper.xml +++ b/src/main/java/neatlogic/module/cmdb/dao/mapper/cischema/CiSchemaMapper.xml @@ -134,7 +134,6 @@ KEY `index_${attrVo.id}` (`${attrVo.id}`) USING BTREE, - KEY `index_${attrVo.id}_hash` (`${attrVo.id}_hash`) USING BTREE, diff --git a/src/main/java/neatlogic/module/cmdb/service/cicatalog/CiCatalogService.java b/src/main/java/neatlogic/module/cmdb/service/cicatalog/CiCatalogService.java new file mode 100644 index 00000000..d6e4b9dd --- /dev/null +++ b/src/main/java/neatlogic/module/cmdb/service/cicatalog/CiCatalogService.java @@ -0,0 +1,23 @@ +package neatlogic.module.cmdb.service.cicatalog; + +import neatlogic.framework.cmdb.dto.cicatalog.CiCatalogNodeVo; +import neatlogic.framework.cmdb.dto.cicatalog.CiCatalogVo; + +import java.util.List; + +public interface CiCatalogService { + + int checkCiCatalogIsExists(Long id); + + int checkCiCatalogNameIsRepeat(CiCatalogVo ciCatalog); + + CiCatalogVo getCiCatalog(Long id); + + List getAllCiCatalogList(); + + int checkCiCatalogIsInUsed(Long id); + + Long saveCiCatalog(CiCatalogVo ciCatalog); + + void deleteCiCatalog(Long id); +} diff --git a/src/main/java/neatlogic/module/cmdb/service/cicatalog/CiCatalogServiceImpl.java b/src/main/java/neatlogic/module/cmdb/service/cicatalog/CiCatalogServiceImpl.java new file mode 100644 index 00000000..4b4425e7 --- /dev/null +++ b/src/main/java/neatlogic/module/cmdb/service/cicatalog/CiCatalogServiceImpl.java @@ -0,0 +1,88 @@ +package neatlogic.module.cmdb.service.cicatalog; + +import neatlogic.framework.cmdb.dto.cicatalog.CiCatalogNodeVo; +import neatlogic.framework.cmdb.dto.cicatalog.CiCatalogVo; +import neatlogic.framework.common.dto.BasePageVo; +import neatlogic.framework.lrcode.LRCodeManager; +import neatlogic.module.cmdb.dao.mapper.cicatalog.CiCatalogMapper; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +@Service +public class CiCatalogServiceImpl implements CiCatalogService { + + @Resource + private CiCatalogMapper ciCatalogMapper; + + @Override + public int checkCiCatalogIsExists(Long id) { + return ciCatalogMapper.checkCiCatalogIsExists(id); + } + + @Override + public int checkCiCatalogNameIsRepeat(CiCatalogVo ciCatalog) { + return ciCatalogMapper.checkCiCatalogNameIsRepeat(ciCatalog); + } + + @Override + public CiCatalogVo getCiCatalog(Long id) { + return ciCatalogMapper.getCiCatalogById(id); + } + + @Override + public List getAllCiCatalogList() { + int rowNum = ciCatalogMapper.getAllCount(); + if (rowNum == 0) { + return new ArrayList<>(); + } + CiCatalogNodeVo rootNode = new CiCatalogNodeVo(); + rootNode.setId(CiCatalogVo.ROOT_ID); + rootNode.setName(CiCatalogVo.ROOT_NAME); + rootNode.setParentId(CiCatalogVo.ROOT_PARENTID); + rootNode.setLft(1); + rootNode.setRht((rowNum + 1) * 2); + List allNodeList = new ArrayList<>(); + allNodeList.add(rootNode); + BasePageVo searchVo = new BasePageVo(); + searchVo.setPageSize(100); + searchVo.setRowNum(rowNum); + int pageCount = searchVo.getPageCount(); + for (int currentPage = 1; currentPage <= pageCount; currentPage++) { + searchVo.setCurrentPage(currentPage); + List serviceNodeList = ciCatalogMapper.getCiCatalogList(searchVo); + allNodeList.addAll(serviceNodeList); + } + return allNodeList; + } + + @Override + public int checkCiCatalogIsInUsed(Long id) { + return ciCatalogMapper.checkCiCatalogIsInUsed(id); + } + + @Override + public Long saveCiCatalog(CiCatalogVo ciCatalog) { + CiCatalogVo oldCiCatalog = ciCatalogMapper.getCiCatalogById(ciCatalog.getId()); + if (oldCiCatalog == null) { + int lft = LRCodeManager.beforeAddTreeNode("cmdb_ci_catalog", "id", "parent_id", ciCatalog.getParentId()); + ciCatalog.setLft(lft); + ciCatalog.setRht(lft + 1); + } else { + if (Objects.equals(oldCiCatalog.getName(), ciCatalog.getName())) { + return ciCatalog.getId(); + } + } + ciCatalogMapper.insertCiCatalog(ciCatalog); + return ciCatalog.getId(); + } + + @Override + public void deleteCiCatalog(Long id) { + LRCodeManager.beforeDeleteTreeNode("cmdb_ci_catalog", "id", "parent_id", id); + ciCatalogMapper.deleteCiCatalog(id); + } +} diff --git a/src/main/resources/neatlogic/resources/cmdb/changelog/2023-12-25/neatlogic_tenant.sql b/src/main/resources/neatlogic/resources/cmdb/changelog/2023-12-25/neatlogic_tenant.sql new file mode 100644 index 00000000..8b2d3483 --- /dev/null +++ b/src/main/resources/neatlogic/resources/cmdb/changelog/2023-12-25/neatlogic_tenant.sql @@ -0,0 +1,15 @@ +CREATE TABLE `cmdb_ci_catalog` ( + `id` bigint NOT NULL COMMENT 'id', + `name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '名称', + `parent_id` bigint NOT NULL COMMENT '父id', + `lft` int DEFAULT NULL COMMENT '左编码', + `rht` int DEFAULT NULL COMMENT '右编码', + PRIMARY KEY (`id`) USING BTREE, + KEY `idx_lft` (`lft`) USING BTREE, + KEY `idx_rht` (`rht`) USING BTREE, + KEY `idx_parent_id` (`parent_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='模型目录'; + +ALTER TABLE `cmdb_ci` + ADD COLUMN `catalog_id` BIGINT NULL COMMENT '模型目录id' AFTER `type_id`; + diff --git a/src/main/resources/neatlogic/resources/cmdb/changelog/2023-12-25/version.json b/src/main/resources/neatlogic/resources/cmdb/changelog/2023-12-25/version.json new file mode 100644 index 00000000..c73c2e2e --- /dev/null +++ b/src/main/resources/neatlogic/resources/cmdb/changelog/2023-12-25/version.json @@ -0,0 +1,12 @@ +{ + "content": [ + { + "type": "新增功能", + "detail": [ + { + "msg": "1.模型目录" + } + ] + } + ] +} diff --git a/src/main/resources/neatlogic/resources/cmdb/sqlscript/ddl.sql b/src/main/resources/neatlogic/resources/cmdb/sqlscript/ddl.sql index a294eb21..8be5051b 100644 --- a/src/main/resources/neatlogic/resources/cmdb/sqlscript/ddl.sql +++ b/src/main/resources/neatlogic/resources/cmdb/sqlscript/ddl.sql @@ -104,6 +104,7 @@ CREATE TABLE IF NOT EXISTS `cmdb_ci` ( `description` varchar(1024) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '描述', `icon` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '图标', `type_id` bigint DEFAULT NULL COMMENT '类型ID ecmdb_ci_type', + `catalog_id` bigint DEFAULT NULL COMMENT '模型目录id', `parent_ci_id` bigint DEFAULT NULL COMMENT '父模型ID', `name_attr_id` bigint DEFAULT NULL COMMENT '名称属性', `lft` int DEFAULT NULL COMMENT '左编码', @@ -996,3 +997,18 @@ CREATE TABLE IF NOT EXISTS `cmdb_resourcecenter_config` ( `lcd` timestamp(3) NULL DEFAULT NULL COMMENT '修改时间', PRIMARY KEY (`id`) USING BTREE ) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '资源中心配置表' ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Table structure for cmdb_ci_catalog +-- ---------------------------- +CREATE TABLE IF NOT EXISTS `cmdb_ci_catalog` ( + `id` bigint NOT NULL COMMENT 'id', + `name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '名称', + `parent_id` bigint NOT NULL COMMENT '父id', + `lft` int DEFAULT NULL COMMENT '左编码', + `rht` int DEFAULT NULL COMMENT '右编码', + PRIMARY KEY (`id`) USING BTREE, + KEY `idx_lft` (`lft`) USING BTREE, + KEY `idx_rht` (`rht`) USING BTREE, + KEY `idx_parent_id` (`parent_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='模型目录'; diff --git a/src/main/resources/neatlogic/resources/cmdb/sqlscript/dml.sql b/src/main/resources/neatlogic/resources/cmdb/sqlscript/dml.sql index f9868b69..09840d04 100644 --- a/src/main/resources/neatlogic/resources/cmdb/sqlscript/dml.sql +++ b/src/main/resources/neatlogic/resources/cmdb/sqlscript/dml.sql @@ -25,3 +25,27 @@ insert ignore into `cmdb_resourcecenter_entity`(`name`,`label`,`status`,`error`, insert ignore into `cmdb_resourcecenter_entity`(`name`,`label`,`status`,`error`,`description`,`init_time`,`ci_id`,`config`) values ('scence_softwareservice_ports','软件服务服务端口场景','ready','',NULL,'2023-12-13 09:10:31.867',478816686317568,'{\"fieldMappingList\":[{\"field\":\"id\",\"fromAttr\":\"_id\",\"fromCi\":\"SoftwareService\",\"type\":\"const\"},{\"field\":\"service_ports_id\",\"fromAttr\":\"service_ports\",\"fromCi\":\"SoftwareService\",\"toAttr\":\"_id\",\"toCi\":\"SoftWareListenPort\",\"type\":\"attr\"},{\"field\":\"name\",\"fromAttr\":\"service_ports\",\"fromCi\":\"SoftwareService\",\"toAttr\":\"name\",\"toCi\":\"SoftWareListenPort\",\"type\":\"attr\"},{\"field\":\"listen_port\",\"fromAttr\":\"service_ports\",\"fromCi\":\"SoftwareService\",\"toAttr\":\"listen_port\",\"toCi\":\"SoftWareListenPort\",\"type\":\"attr\"}],\"mainCi\":\"SoftwareService\"}'); insert ignore into `cmdb_resourcecenter_entity`(`name`,`label`,`status`,`error`,`description`,`init_time`,`ci_id`,`config`) values ('scence_state','资产状态基本信息场景','ready','',NULL,'2023-12-13 09:10:31.894',479550169423872,'{\"fieldMappingList\":[{\"field\":\"id\",\"fromAttr\":\"_id\",\"fromCi\":\"CIState\",\"type\":\"const\"},{\"field\":\"name\",\"fromAttr\":\"name\",\"fromCi\":\"CIState\",\"type\":\"attr\"},{\"field\":\"description\",\"fromAttr\":\"label\",\"fromCi\":\"CIState\",\"type\":\"attr\"}],\"mainCi\":\"CIState\"}'); insert ignore into `cmdb_resourcecenter_entity`(`name`,`label`,`status`,`error`,`description`,`init_time`,`ci_id`,`config`) values ('scence_vendor','厂商基本信息场景','ready','',NULL,'2023-12-13 09:10:31.921',480863598731264,'{\"fieldMappingList\":[{\"field\":\"id\",\"fromAttr\":\"_id\",\"fromCi\":\"Vendor\",\"type\":\"const\"},{\"field\":\"name\",\"fromAttr\":\"name\",\"fromCi\":\"Vendor\",\"type\":\"attr\"},{\"field\":\"description\",\"fromAttr\":\"label\",\"fromCi\":\"Vendor\",\"type\":\"attr\"}],\"mainCi\":\"Vendor\"}'); + +-- ---------------------------- +-- Records of cmdb_global_attr +-- ---------------------------- +insert ignore into `cmdb_global_attr`(`id`,`name`,`label`,`is_active`,`is_multiple`,`description`) values (979768512987136,'app_environment','应用环境',1,0,NULL); + +-- ---------------------------- +-- Records of cmdb_global_attritem +-- ---------------------------- +insert ignore into `cmdb_global_attritem`(`id`,`attr_id`,`value`,`sort`) values (481856650534914,979768512987136,'PRD',4); +insert ignore into `cmdb_global_attritem`(`id`,`attr_id`,`value`,`sort`) values (481856650534918,979768512987136,'UAT',3); +insert ignore into `cmdb_global_attritem`(`id`,`attr_id`,`value`,`sort`) values (481856650534925,979768512987136,'SIT',2); +insert ignore into `cmdb_global_attritem`(`id`,`attr_id`,`value`,`sort`) values (699864006320129,979768512987136,'DEV',1); + +-- ---------------------------- +-- Records of cmdb_viewconst +-- ---------------------------- +INSERT ignore INTO `cmdb_viewconst` (`id`, `name`, `label`) VALUES (1, '_id', 'ID#'); +INSERT ignore INTO `cmdb_viewconst` (`id`, `name`, `label`) VALUES (2, '_ciLabel', '模型'); +INSERT ignore INTO `cmdb_viewconst` (`id`, `name`, `label`) VALUES (3, '_typeName', '类型'); +INSERT ignore INTO `cmdb_viewconst` (`id`, `name`, `label`) VALUES (4, '_inspectTime', '巡检时间'); +INSERT ignore INTO `cmdb_viewconst` (`id`, `name`, `label`) VALUES (5, '_inspectStatus', '巡检状态'); +INSERT ignore INTO `cmdb_viewconst` (`id`, `name`, `label`) VALUES (6, '_monitorTime', '监控时间'); +INSERT ignore INTO `cmdb_viewconst` (`id`, `name`, `label`) VALUES (7, '_monitorStatus', '监控状态'); diff --git a/src/main/resources/neatlogic/resources/cmdb/sqlscript/dmldemo.sql b/src/main/resources/neatlogic/resources/cmdb/sqlscript/dmldemo.sql index 1861f1d9..bb849363 100644 --- a/src/main/resources/neatlogic/resources/cmdb/sqlscript/dmldemo.sql +++ b/src/main/resources/neatlogic/resources/cmdb/sqlscript/dmldemo.sql @@ -14766,17 +14766,6 @@ INSERT INTO `cmdb_view` (`ci_id`, `item_id`, `type`, `sort`, `show_type`, `allow INSERT INTO `cmdb_view` (`ci_id`, `item_id`, `type`, `sort`, `show_type`, `allow_edit`) VALUES (827468374089728, 827468374089729, 'attr', 3, 'all', 1); INSERT INTO `cmdb_view` (`ci_id`, `item_id`, `type`, `sort`, `show_type`, `allow_edit`) VALUES (827468374089728, 827468374089730, 'attr', 5, 'all', 1); --- ---------------------------- --- Records of cmdb_viewconst --- ---------------------------- -INSERT INTO `cmdb_viewconst` (`id`, `name`, `label`) VALUES (1, '_id', 'ID#'); -INSERT INTO `cmdb_viewconst` (`id`, `name`, `label`) VALUES (2, '_ciLabel', '模型'); -INSERT INTO `cmdb_viewconst` (`id`, `name`, `label`) VALUES (3, '_typeName', '类型'); -INSERT INTO `cmdb_viewconst` (`id`, `name`, `label`) VALUES (4, '_inspectTime', '巡检时间'); -INSERT INTO `cmdb_viewconst` (`id`, `name`, `label`) VALUES (5, '_inspectStatus', '巡检状态'); -INSERT INTO `cmdb_viewconst` (`id`, `name`, `label`) VALUES (6, '_monitorTime', '监控时间'); -INSERT INTO `cmdb_viewconst` (`id`, `name`, `label`) VALUES (7, '_monitorStatus', '监控状态'); - -- ---------------------------- -- Records of cmdb_resourcecenter_type_ci -- ---------------------------- -- Gitee