From 19f4e56e5dfdbd59f74acdf4d88356ea110a0fce Mon Sep 17 00:00:00 2001 From: linbangquan <1437892690@qq.com> Date: Sun, 19 Nov 2023 15:27:33 +0800 Subject: [PATCH] =?UTF-8?q?[=E5=8A=9F=E8=83=BD]=20=E8=A7=86=E5=9B=BE?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE-=E5=A2=9E=E5=8A=A0=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E8=A7=86=E5=9B=BE=E6=95=B0=E6=8D=AE=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 关联 #[1023682900623360]视图设置-增加显示视图数据功能 http://192.168.0.96:8090/demo/rdm.html#/story-detail/939050947543040/939050947543042/1023682900623360 --- .../getResourceEntityViewDataListApi.java | 72 +++++++++++++++++++ .../resourcecenter/ResourceEntityMapper.java | 6 ++ .../resourcecenter/ResourceEntityMapper.xml | 9 +++ 3 files changed, 87 insertions(+) create mode 100644 src/main/java/neatlogic/module/cmdb/api/resourcecenter/config/getResourceEntityViewDataListApi.java diff --git a/src/main/java/neatlogic/module/cmdb/api/resourcecenter/config/getResourceEntityViewDataListApi.java b/src/main/java/neatlogic/module/cmdb/api/resourcecenter/config/getResourceEntityViewDataListApi.java new file mode 100644 index 00000000..1417aa3b --- /dev/null +++ b/src/main/java/neatlogic/module/cmdb/api/resourcecenter/config/getResourceEntityViewDataListApi.java @@ -0,0 +1,72 @@ +package neatlogic.module.cmdb.api.resourcecenter.config; + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import neatlogic.framework.asynchronization.threadlocal.TenantContext; +import neatlogic.framework.auth.core.AuthAction; +import neatlogic.framework.cmdb.auth.label.CMDB; +import neatlogic.framework.common.constvalue.ApiParamType; +import neatlogic.framework.common.dto.BasePageVo; +import neatlogic.framework.dao.mapper.SchemaMapper; +import neatlogic.framework.restful.annotation.*; +import neatlogic.framework.restful.constvalue.OperationTypeEnum; +import neatlogic.framework.restful.core.privateapi.PrivateApiComponentBase; +import neatlogic.framework.util.TableResultUtil; +import neatlogic.module.cmdb.dao.mapper.resourcecenter.ResourceEntityMapper; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.List; +import java.util.Map; + +@Service +@AuthAction(action = CMDB.class) +@OperationType(type = OperationTypeEnum.SEARCH) +public class getResourceEntityViewDataListApi extends PrivateApiComponentBase { + + @Resource + private ResourceEntityMapper resourceEntityMapper; + + @Resource + private SchemaMapper schemaMapper; + + @Override + public String getName() { + return "nmcarc.getresourceentityviewdatalistapi.getname"; + } + + @Input({ + @Param(name = "name", type = ApiParamType.STRING, isRequired = true, desc = "common.name"), + @Param(name = "currentPage", type = ApiParamType.INTEGER, desc = "common.currentpage"), + @Param(name = "pageSize", type = ApiParamType.INTEGER, desc = "common.pagesize"), + }) + @Output({ + @Param(name = "Return", type = ApiParamType.JSONOBJECT, desc = "common.tbodylist") + }) + @Description(desc = "nmcarc.getresourceentityviewdatalistapi.getname") + @Override + public Object myDoService(JSONObject paramObj) throws Exception { + String name = paramObj.getString("name"); + JSONArray theadList = new JSONArray(); + List columnNameList = schemaMapper.getTableOrViewAllColumnNameList(TenantContext.get().getDataDbName(), name); + for (String columnName : columnNameList) { + JSONObject thead = new JSONObject(); + thead.put("key", columnName); + thead.put("title", columnName); + theadList.add(thead); + } + BasePageVo basePageVo = paramObj.toJavaObject(BasePageVo.class); + int rowNum = resourceEntityMapper.getResourceEntityViewDataCount(name); + if (rowNum == 0) { + return new JSONObject(); + } + basePageVo.setRowNum(rowNum); + List> tbodyList = resourceEntityMapper.getResourceEntityViewDataList(name, basePageVo.getStartNum(), basePageVo.getPageSize()); + return TableResultUtil.getResult(theadList, tbodyList, basePageVo); + } + + @Override + public String getToken() { + return "resourcecenter/resourceentity/viewdata/list"; + } +} diff --git a/src/main/java/neatlogic/module/cmdb/dao/mapper/resourcecenter/ResourceEntityMapper.java b/src/main/java/neatlogic/module/cmdb/dao/mapper/resourcecenter/ResourceEntityMapper.java index b5a3da1e..5ce39578 100644 --- a/src/main/java/neatlogic/module/cmdb/dao/mapper/resourcecenter/ResourceEntityMapper.java +++ b/src/main/java/neatlogic/module/cmdb/dao/mapper/resourcecenter/ResourceEntityMapper.java @@ -18,8 +18,10 @@ package neatlogic.module.cmdb.dao.mapper.resourcecenter; import neatlogic.framework.cmdb.crossover.IResourceEntityCrossoverMapper; import neatlogic.framework.cmdb.dto.resourcecenter.config.ResourceEntityVo; +import org.apache.ibatis.annotations.Param; import java.util.List; +import java.util.Map; public interface ResourceEntityMapper extends IResourceEntityCrossoverMapper { ResourceEntityVo getResourceEntityByName(String name); @@ -30,6 +32,10 @@ public interface ResourceEntityMapper extends IResourceEntityCrossoverMapper { List getAllResourceTypeCiIdList(); + int getResourceEntityViewDataCount(String name); + + List> getResourceEntityViewDataList(@Param("name") String name, @Param("startNum") int startNum, @Param("pageSize") int pageSize); + void insertResourceEntity(ResourceEntityVo resourceEntityVo); void insertResourceTypeCi(Long ciId); diff --git a/src/main/java/neatlogic/module/cmdb/dao/mapper/resourcecenter/ResourceEntityMapper.xml b/src/main/java/neatlogic/module/cmdb/dao/mapper/resourcecenter/ResourceEntityMapper.xml index c2752803..9c7d670c 100644 --- a/src/main/java/neatlogic/module/cmdb/dao/mapper/resourcecenter/ResourceEntityMapper.xml +++ b/src/main/java/neatlogic/module/cmdb/dao/mapper/resourcecenter/ResourceEntityMapper.xml @@ -43,6 +43,15 @@ limitations under the License. SELECT `ci_id` FROM `cmdb_resourcecenter_type_ci` + + + + INSERT INTO cmdb_resourcecenter_entity (`name`, `label`, `status`, `error`, `init_time`, `ci_id`, `config`, `description`) -- Gitee