diff --git a/src/main/java/neatlogic/module/cmdb/api/resourcecenter/appmodule/AppModuleResourceListApi.java b/src/main/java/neatlogic/module/cmdb/api/resourcecenter/app/AppResourceListApi.java
similarity index 60%
rename from src/main/java/neatlogic/module/cmdb/api/resourcecenter/appmodule/AppModuleResourceListApi.java
rename to src/main/java/neatlogic/module/cmdb/api/resourcecenter/app/AppResourceListApi.java
index 29243743478c30b99a97c3c5b95d6e31da12609a..68263d314efb670f5814b48c6326348056b1a7c1 100644
--- a/src/main/java/neatlogic/module/cmdb/api/resourcecenter/appmodule/AppModuleResourceListApi.java
+++ b/src/main/java/neatlogic/module/cmdb/api/resourcecenter/app/AppResourceListApi.java
@@ -13,21 +13,23 @@ GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see .*/
-package neatlogic.module.cmdb.api.resourcecenter.appmodule;
+package neatlogic.module.cmdb.api.resourcecenter.app;
+import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import neatlogic.framework.auth.core.AuthAction;
import neatlogic.framework.cmdb.auth.label.CMDB_BASE;
-import neatlogic.framework.cmdb.dto.resourcecenter.ResourceSearchVo;
+import neatlogic.framework.cmdb.resourcecenter.datasource.core.IResourceCenterDataSource;
+import neatlogic.framework.cmdb.resourcecenter.datasource.core.ResourceCenterDataSourceFactory;
import neatlogic.framework.common.constvalue.ApiParamType;
import neatlogic.framework.exception.type.ParamNotExistsException;
import neatlogic.framework.restful.annotation.*;
import neatlogic.framework.restful.constvalue.OperationTypeEnum;
import neatlogic.framework.restful.core.privateapi.PrivateApiComponentBase;
-import neatlogic.module.cmdb.service.resourcecenter.resource.IResourceCenterResourceService;
import org.springframework.stereotype.Service;
-import javax.annotation.Resource;
+import java.util.ArrayList;
+import java.util.List;
/**
* @author linbq
@@ -36,19 +38,16 @@ import javax.annotation.Resource;
@Service
@AuthAction(action = CMDB_BASE.class)
@OperationType(type = OperationTypeEnum.SEARCH)
-public class AppModuleResourceListApi extends PrivateApiComponentBase {
-
- @Resource
- private IResourceCenterResourceService resourceCenterResourceService;
+public class AppResourceListApi extends PrivateApiComponentBase {
@Override
public String getToken() {
- return "resourcecenter/appmodule/resource/list";
+ return "resourcecenter/app/resource/list";
}
@Override
public String getName() {
- return "查询应用模块中资源列表";
+ return "查询应用中资源列表";
}
@Override
@@ -60,10 +59,9 @@ public class AppModuleResourceListApi extends PrivateApiComponentBase {
@Param(name = "appSystemId", type = ApiParamType.LONG, desc = "应用id"),
@Param(name = "appModuleId", type = ApiParamType.LONG, desc = "应用模块id"),
@Param(name = "envId", type = ApiParamType.LONG, desc = "环境id,envId=-2表示无配置环境"),
- @Param(name = "typeId", type = ApiParamType.LONG, desc = "类型id"),
- @Param(name = "currentPage", type = ApiParamType.INTEGER, desc = "当前页"),
- @Param(name = "pageSize", type = ApiParamType.INTEGER, desc = "每页数据条目"),
- @Param(name = "needPage", type = ApiParamType.BOOLEAN, desc = "是否需要分页,默认true")
+ @Param(name = "viewName", type = ApiParamType.STRING, desc = "视图名称"),
+ @Param(name = "currentPage", type = ApiParamType.INTEGER, defaultValue = "1", desc = "当前页"),
+ @Param(name = "pageSize", type = ApiParamType.INTEGER, defaultValue = "20", desc = "每页数据条目")
})
@Output({
@Param(name = "tableList", type = ApiParamType.JSONARRAY, desc = "资源环境列表")
@@ -72,11 +70,23 @@ public class AppModuleResourceListApi extends PrivateApiComponentBase {
@Override
public Object myDoService(JSONObject paramObj) throws Exception {
JSONObject resultObj = new JSONObject();
- ResourceSearchVo searchVo = paramObj.toJavaObject(ResourceSearchVo.class);
- if (searchVo.getAppSystemId() == null && searchVo.getAppModuleId() == null) {
+ Long appSystemId = paramObj.getLong("appSystemId");
+ Long appModuleId = paramObj.getLong("appModuleId");
+ if (appSystemId == null && appModuleId == null) {
throw new ParamNotExistsException("应用id(appSystemId)", "应用模块id(appModuleId)");
}
- resultObj.put("tableList", resourceCenterResourceService.getAppModuleResourceList(searchVo));
+ Long envId = paramObj.getLong("envId");
+ Integer currentPage = paramObj.getInteger("currentPage");
+ Integer pageSize = paramObj.getInteger("pageSize");
+ Long typeId = paramObj.getLong("typeId");
+ List typeIdList = new ArrayList<>();
+ if (typeId != null) {
+ typeIdList.add(typeId);
+ }
+ String viewName = paramObj.getString("viewName");
+ IResourceCenterDataSource resourceCenterDataSource = ResourceCenterDataSourceFactory.getResourceCenterDataSource();
+ JSONArray tableList = resourceCenterDataSource.getAppResourceList(appSystemId, appModuleId, envId, null, viewName, currentPage, pageSize);
+ resultObj.put("tableList", tableList);
return resultObj;
}
}
diff --git a/src/main/java/neatlogic/module/cmdb/api/resourcecenter/app/ListAppSystemForSelectApi.java b/src/main/java/neatlogic/module/cmdb/api/resourcecenter/app/ListAppSystemForSelectApi.java
index d6d3b8f15df10e29a5bbca77cb40463c58ae4196..9ddf4eb25f974ba685ad05bc713e743b6d1330a6 100644
--- a/src/main/java/neatlogic/module/cmdb/api/resourcecenter/app/ListAppSystemForSelectApi.java
+++ b/src/main/java/neatlogic/module/cmdb/api/resourcecenter/app/ListAppSystemForSelectApi.java
@@ -15,23 +15,20 @@ along with this program. If not, see .*/
package neatlogic.module.cmdb.api.resourcecenter.app;
-import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import neatlogic.framework.auth.core.AuthAction;
import neatlogic.framework.cmdb.auth.label.CMDB;
import neatlogic.framework.cmdb.dto.resourcecenter.ResourceVo;
+import neatlogic.framework.cmdb.resourcecenter.datasource.core.IResourceCenterDataSource;
+import neatlogic.framework.cmdb.resourcecenter.datasource.core.ResourceCenterDataSourceFactory;
import neatlogic.framework.common.constvalue.ApiParamType;
import neatlogic.framework.common.dto.BasePageVo;
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.ResourceMapper;
-import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Service;
-import javax.annotation.Resource;
-import java.util.ArrayList;
import java.util.List;
@Service
@@ -39,9 +36,6 @@ import java.util.List;
@OperationType(type = OperationTypeEnum.SEARCH)
public class ListAppSystemForSelectApi extends PrivateApiComponentBase {
- @Resource
- private ResourceMapper resourceMapper;
-
@Override
public String getToken() {
return "resourcecenter/appsystem/list/forselect";
@@ -71,32 +65,8 @@ public class ListAppSystemForSelectApi extends PrivateApiComponentBase {
@Override
public Object myDoService(JSONObject paramObj) throws Exception {
BasePageVo searchVo = paramObj.toJavaObject(BasePageVo.class);
- JSONArray defaultValue = searchVo.getDefaultValue();
- if (CollectionUtils.isNotEmpty(defaultValue)) {
- List idList = defaultValue.toJavaList(Long.class);
- List resourceList = resourceMapper.searchAppSystemListByIdList(idList);
- return TableResultUtil.getResult(resourceList);
- } else {
- int rowNum = resourceMapper.searchAppSystemCount(searchVo);
- if (rowNum > 0) {
- searchVo.setRowNum(rowNum);
- if (searchVo.getNeedPage()) {
- List idList = resourceMapper.searchAppSystemIdList(searchVo);
- List resourceList = resourceMapper.searchAppSystemListByIdList(idList);
- return TableResultUtil.getResult(resourceList, searchVo);
- } else {
- List allResourceList = new ArrayList<>();
- int pageCount = searchVo.getPageCount();
- for (int currentPage = 1; currentPage <= pageCount; currentPage++) {
- searchVo.setCurrentPage(currentPage);
- List idList = resourceMapper.searchAppSystemIdList(searchVo);
- List resourceList = resourceMapper.searchAppSystemListByIdList(idList);
- allResourceList.addAll(resourceList);
- }
- return TableResultUtil.getResult(allResourceList, searchVo);
- }
- }
- }
- return null;
+ IResourceCenterDataSource resourceCenterDataSource = ResourceCenterDataSourceFactory.getResourceCenterDataSource();
+ List tbodyList = resourceCenterDataSource.getAppSystemListForSelect(searchVo);
+ return TableResultUtil.getResult(tbodyList, searchVo);
}
}
diff --git a/src/main/java/neatlogic/module/cmdb/api/resourcecenter/app/ListAppSystemForTreeApi.java b/src/main/java/neatlogic/module/cmdb/api/resourcecenter/app/ListAppSystemForTreeApi.java
index dcc095bb03da6c80e55ce0a7f17d805fec395bc6..d572887299f1a50ec9dd2430aaba8621f017d6ba 100644
--- a/src/main/java/neatlogic/module/cmdb/api/resourcecenter/app/ListAppSystemForTreeApi.java
+++ b/src/main/java/neatlogic/module/cmdb/api/resourcecenter/app/ListAppSystemForTreeApi.java
@@ -18,33 +18,24 @@ package neatlogic.module.cmdb.api.resourcecenter.app;
import com.alibaba.fastjson.JSONObject;
import neatlogic.framework.auth.core.AuthAction;
import neatlogic.framework.cmdb.auth.label.CMDB;
-import neatlogic.framework.cmdb.dto.resourcecenter.AppModuleVo;
import neatlogic.framework.cmdb.dto.resourcecenter.AppSystemVo;
+import neatlogic.framework.cmdb.resourcecenter.datasource.core.IResourceCenterDataSource;
+import neatlogic.framework.cmdb.resourcecenter.datasource.core.ResourceCenterDataSourceFactory;
import neatlogic.framework.common.constvalue.ApiParamType;
import neatlogic.framework.common.dto.BasePageVo;
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.ResourceMapper;
-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.class)
@OperationType(type = OperationTypeEnum.SEARCH)
public class ListAppSystemForTreeApi extends PrivateApiComponentBase {
- @Resource
- private ResourceMapper resourceMapper;
-
@Override
public String getToken() {
return "resourcecenter/appsystem/list/fortree";
@@ -72,42 +63,9 @@ public class ListAppSystemForTreeApi extends PrivateApiComponentBase {
@Description(desc = "查询资源应用列表")
@Override
public Object myDoService(JSONObject paramObj) throws Exception {
- List tbodyList = new ArrayList<>();
BasePageVo searchVo = paramObj.toJavaObject(BasePageVo.class);
- String keyword = searchVo.getKeyword();
- int count = resourceMapper.getAppSystemIdListCountByKeyword(keyword);
- if (count > 0) {
- searchVo.setRowNum(count);
- List appSystemIdList = resourceMapper.getAppSystemIdListByKeyword(searchVo);
- if (CollectionUtils.isEmpty(appSystemIdList)) {
- return TableResultUtil.getResult(tbodyList, searchVo);
- }
- tbodyList = resourceMapper.getAppSystemListByIdList(appSystemIdList);
- List hasModuleAppSystemIdList = resourceMapper.getHasModuleAppSystemIdListByAppSystemIdList(appSystemIdList);
- if (CollectionUtils.isNotEmpty(hasModuleAppSystemIdList)) {
- for (AppSystemVo appSystemVo : tbodyList) {
- if (hasModuleAppSystemIdList.contains(appSystemVo.getId())) {
- appSystemVo.setIsHasModule(1);
- }
- }
- }
- if (StringUtils.isNotEmpty(searchVo.getKeyword())) {
- List appModuleList = resourceMapper.getAppModuleListByKeywordAndAppSystemIdList(keyword, appSystemIdList);
- if (CollectionUtils.isNotEmpty(appModuleList)) {
- Map> appModuleMap = new HashMap<>();
- for (AppModuleVo appModuleVo : appModuleList) {
- appModuleMap.computeIfAbsent(appModuleVo.getAppSystemId(), key -> new ArrayList<>()).add(appModuleVo);
- }
- for (AppSystemVo appSystemVo : tbodyList) {
- List appModuleVoList = appModuleMap.get(appSystemVo.getId());
- if (CollectionUtils.isNotEmpty(appModuleVoList)) {
- appSystemVo.setAppModuleList(appModuleVoList);
- appSystemVo.setIsHasModule(1);
- }
- }
- }
- }
- }
+ IResourceCenterDataSource resourceCenterDataSource = ResourceCenterDataSourceFactory.getResourceCenterDataSource();
+ List tbodyList = resourceCenterDataSource.getAppSystemListForTree(searchVo);
return TableResultUtil.getResult(tbodyList, searchVo);
}
}
diff --git a/src/main/java/neatlogic/module/cmdb/api/resourcecenter/appenv/ListAppEnvForSelectApi.java b/src/main/java/neatlogic/module/cmdb/api/resourcecenter/appenv/ListAppEnvForSelectApi.java
index ffa53bb78a70a83d8414878178db89da0398d86e..34f801b297ee31ad283f9879bfaaf98edee34c82 100644
--- a/src/main/java/neatlogic/module/cmdb/api/resourcecenter/appenv/ListAppEnvForSelectApi.java
+++ b/src/main/java/neatlogic/module/cmdb/api/resourcecenter/appenv/ListAppEnvForSelectApi.java
@@ -15,23 +15,20 @@ along with this program. If not, see .*/
package neatlogic.module.cmdb.api.resourcecenter.appenv;
-import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import neatlogic.framework.auth.core.AuthAction;
import neatlogic.framework.cmdb.auth.label.CMDB;
import neatlogic.framework.cmdb.dto.resourcecenter.ResourceVo;
+import neatlogic.framework.cmdb.resourcecenter.datasource.core.IResourceCenterDataSource;
+import neatlogic.framework.cmdb.resourcecenter.datasource.core.ResourceCenterDataSourceFactory;
import neatlogic.framework.common.constvalue.ApiParamType;
import neatlogic.framework.common.dto.BasePageVo;
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.ResourceMapper;
-import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Service;
-import javax.annotation.Resource;
-import java.util.ArrayList;
import java.util.List;
@Service
@@ -39,9 +36,6 @@ import java.util.List;
@OperationType(type = OperationTypeEnum.SEARCH)
public class ListAppEnvForSelectApi extends PrivateApiComponentBase {
- @Resource
- private ResourceMapper resourceMapper;
-
@Override
public String getToken() {
return "resourcecenter/appenv/list/forselect";
@@ -72,36 +66,8 @@ public class ListAppEnvForSelectApi extends PrivateApiComponentBase {
@Override
public Object myDoService(JSONObject paramObj) throws Exception {
BasePageVo searchVo = paramObj.toJavaObject(BasePageVo.class);
- JSONArray defaultValue = searchVo.getDefaultValue();
- if (CollectionUtils.isNotEmpty(defaultValue)) {
- List idList = defaultValue.toJavaList(Long.class);
- List resourceList = resourceMapper.searchAppEnvListByIdList(idList);
- return TableResultUtil.getResult(resourceList);
- } else {
- int rowNum = resourceMapper.searchAppEnvCount(searchVo);
- if (rowNum > 0) {
- searchVo.setRowNum(rowNum);
- if (searchVo.getNeedPage()) {
- List idList = resourceMapper.searchAppEnvIdList(searchVo);
- if (CollectionUtils.isNotEmpty(idList)) {
- List resourceList = resourceMapper.searchAppEnvListByIdList(idList);
- return TableResultUtil.getResult(resourceList, searchVo);
- }
- } else {
- List allResourceList = new ArrayList<>();
- int pageCount = searchVo.getPageCount();
- for (int currentPage = 1; currentPage <= pageCount; currentPage++) {
- searchVo.setCurrentPage(currentPage);
- List idList = resourceMapper.searchAppEnvIdList(searchVo);
- if (CollectionUtils.isNotEmpty(idList)) {
- List resourceList = resourceMapper.searchAppEnvListByIdList(idList);
- allResourceList.addAll(resourceList);
- }
- }
- return TableResultUtil.getResult(allResourceList, searchVo);
- }
- }
- }
- return null;
+ IResourceCenterDataSource resourceCenterDataSource = ResourceCenterDataSourceFactory.getResourceCenterDataSource();
+ List tbodyList = resourceCenterDataSource.getAppEnvListForSelect(searchVo);
+ return TableResultUtil.getResult(tbodyList, searchVo);
}
}
diff --git a/src/main/java/neatlogic/module/cmdb/api/resourcecenter/appmodule/AppModuleListApi.java b/src/main/java/neatlogic/module/cmdb/api/resourcecenter/appmodule/AppModuleListApi.java
index 86e1e929bf2e94ee08d352dfab6f11f8aa7de232..c95724fec75c8d7b9e96e9b2b1825465393e3ec0 100644
--- a/src/main/java/neatlogic/module/cmdb/api/resourcecenter/appmodule/AppModuleListApi.java
+++ b/src/main/java/neatlogic/module/cmdb/api/resourcecenter/appmodule/AppModuleListApi.java
@@ -20,16 +20,17 @@ import neatlogic.framework.auth.core.AuthAction;
import neatlogic.framework.cmdb.auth.label.CMDB;
import neatlogic.framework.cmdb.dto.resourcecenter.ResourceSearchVo;
import neatlogic.framework.cmdb.dto.resourcecenter.ResourceVo;
+import neatlogic.framework.cmdb.resourcecenter.datasource.core.IResourceCenterDataSource;
+import neatlogic.framework.cmdb.resourcecenter.datasource.core.ResourceCenterDataSourceFactory;
import neatlogic.framework.common.constvalue.ApiParamType;
import neatlogic.framework.common.dto.BasePageVo;
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.service.resourcecenter.resource.IResourceCenterResourceService;
import org.springframework.stereotype.Service;
-import javax.annotation.Resource;
+import java.util.List;
/**
* @author linbq
@@ -40,9 +41,6 @@ import javax.annotation.Resource;
@OperationType(type = OperationTypeEnum.SEARCH)
public class AppModuleListApi extends PrivateApiComponentBase {
- @Resource
- private IResourceCenterResourceService resourceCenterResourceService;
-
@Override
public String getToken() {
return "resourcecenter/appmodule/list";
@@ -73,6 +71,8 @@ public class AppModuleListApi extends PrivateApiComponentBase {
@Override
public Object myDoService(JSONObject paramObj) throws Exception {
ResourceSearchVo searchVo = paramObj.toJavaObject(ResourceSearchVo.class);
- return TableResultUtil.getResult(resourceCenterResourceService.getAppModuleList(searchVo), searchVo);
+ IResourceCenterDataSource resourceCenterDataSource = ResourceCenterDataSourceFactory.getResourceCenterDataSource();
+ List tbodyList = resourceCenterDataSource.getAppModuleList(searchVo);
+ return TableResultUtil.getResult(tbodyList, searchVo);
}
}
diff --git a/src/main/java/neatlogic/module/cmdb/api/resourcecenter/appmodule/AppModuleResourceTypeListApi.java b/src/main/java/neatlogic/module/cmdb/api/resourcecenter/appmodule/AppModuleResourceTypeListApi.java
index fc995848eda76a7779c6672d35764bb3de8fdc69..169c8ed755a1463ca261db5c8ed9e5bc8da383f6 100644
--- a/src/main/java/neatlogic/module/cmdb/api/resourcecenter/appmodule/AppModuleResourceTypeListApi.java
+++ b/src/main/java/neatlogic/module/cmdb/api/resourcecenter/appmodule/AppModuleResourceTypeListApi.java
@@ -7,8 +7,9 @@ import neatlogic.framework.cmdb.auth.label.CMDB;
import neatlogic.framework.cmdb.dto.ci.CiVo;
import neatlogic.framework.cmdb.dto.resourcecenter.ResourceSearchVo;
import neatlogic.framework.cmdb.dto.resourcecenter.ResourceVo;
-import neatlogic.framework.cmdb.enums.resourcecenter.AppModuleResourceType;
import neatlogic.framework.cmdb.exception.ci.CiNotFoundException;
+import neatlogic.framework.cmdb.resourcecenter.datasource.core.IResourceCenterDataSource;
+import neatlogic.framework.cmdb.resourcecenter.datasource.core.ResourceCenterDataSourceFactory;
import neatlogic.framework.common.constvalue.ApiParamType;
import neatlogic.framework.common.dto.BasePageVo;
import neatlogic.framework.restful.annotation.*;
@@ -16,7 +17,6 @@ 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.dao.mapper.resourcecenter.ResourceMapper;
-import neatlogic.module.cmdb.service.resourcecenter.resource.IResourceCenterResourceService;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Service;
@@ -38,9 +38,6 @@ public class AppModuleResourceTypeListApi extends PrivateApiComponentBase {
@Resource
ResourceMapper resourceMapper;
- @Resource
- private IResourceCenterResourceService resourceCenterResourceService;
-
@Override
public String getName() {
return "查询当前模块各环境的需要显示的模型列表";
@@ -72,19 +69,7 @@ public class AppModuleResourceTypeListApi extends PrivateApiComponentBase {
public Object myDoService(JSONObject paramObj) throws Exception {
JSONArray returnArray = new JSONArray();
Long appModuleId = paramObj.getLong("appModuleId");
- //获取应用环境模型
-// CiVo envCiVo = ciMapper.getCiByName("APPEnv");
-// if (envCiVo == null) {
-// throw new CiNotFoundException("APPEnv");
-// }
- //获取需要采集的模型
- List resourceTypeNameList = AppModuleResourceType.getNameList();
- List resourceCiVoList = new ArrayList<>();
List envResourceList = new ArrayList<>();
- //获取应用环境实例list
-// CiEntityVo envCiEntityVo = new CiEntityVo();
-// envCiEntityVo.setCiId(envCiVo.getId());
-// List envIdList = ciEntityMapper.getCiEntityIdByCiId(envCiEntityVo);
BasePageVo search = new BasePageVo();
search.setCurrentPage(1);
search.setPageSize(100);
@@ -97,9 +82,6 @@ public class AppModuleResourceTypeListApi extends PrivateApiComponentBase {
List allCiVoList = ciMapper.getAllCi(null);
for (CiVo ci : allCiVoList) {
allCiVoMap.put(ci.getId(), ci);
- if (resourceTypeNameList.contains(ci.getName())) {
- resourceCiVoList.add(ci);
- }
}
ResourceSearchVo searchVo = new ResourceSearchVo();
searchVo.setAppModuleId(appModuleId);
@@ -111,27 +93,21 @@ public class AppModuleResourceTypeListApi extends PrivateApiComponentBase {
for (ResourceVo envResource : envResourceList) {
JSONObject returnObj = new JSONObject();
searchVo.setEnvId(envResource.getId());
- //根据模块id和环境id,获取当前环境下含有资产的 模型idList(resourceTypeIdList)
- Set resourceTypeIdSet = resourceMapper.getIpObjectResourceTypeIdListByAppModuleIdAndEnvId(searchVo);
- List resourceTypeIdList = new ArrayList<>(resourceTypeIdSet);
- Set returnCiVoSet = new HashSet<>();
- if (CollectionUtils.isNotEmpty(resourceTypeIdSet)) {
- resourceTypeIdSet = resourceMapper.getOsResourceTypeIdListByAppModuleIdAndEnvId(searchVo);
- resourceTypeIdList.addAll(resourceTypeIdSet);
+ Set typeIdSet = new HashSet<>();
+ IResourceCenterDataSource resourceCenterDataSource = ResourceCenterDataSourceFactory.getResourceCenterDataSource();
+ Map> viewName2TypeIdListMap = resourceCenterDataSource.getAppResourceTypeIdListByAppSystemIdAndAppModuleIdAndEnvId(null, appModuleId, envResource.getId());
+ for (Map.Entry> entry : viewName2TypeIdListMap.entrySet()) {
+ String viewName = entry.getKey();
+ searchVo.setViewName(viewName);
+ typeIdSet.addAll(entry.getValue());
}
-
- //循环resourceTypeIdList,将其父级模型的name存在于resourceTypeNameList中的 模型 返回给前端
- if (CollectionUtils.isNotEmpty(resourceTypeIdList)) {
- for (Long resourceTypeId : resourceTypeIdList) {
- CiVo ciVo = allCiVoMap.get(resourceTypeId);
- if (ciVo == null) {
- throw new CiNotFoundException(resourceTypeId);
- }
- String resourceTypeName = resourceCenterResourceService.getResourceTypeName(resourceCiVoList, ciVo);
- if (resourceTypeNameList.contains(resourceTypeName)) {
- returnCiVoSet.add(ciVo);
- }
+ Set returnCiVoSet = new HashSet<>();
+ for (Long typeId : typeIdSet) {
+ CiVo ciVo = allCiVoMap.get(typeId);
+ if (ciVo == null) {
+ throw new CiNotFoundException(typeId);
}
+ returnCiVoSet.add(ciVo);
}
if (CollectionUtils.isNotEmpty(returnCiVoSet)) {
returnObj.put("env", envResource);
diff --git a/src/main/java/neatlogic/module/cmdb/api/resourcecenter/appmodule/ListAppModuleListForTreeApi.java b/src/main/java/neatlogic/module/cmdb/api/resourcecenter/appmodule/ListAppModuleListForTreeApi.java
index 6a58ddf24c9d42bf2bcc85fdcc80f40c358d994c..f32f8697ba6a9aee832a6ea6f235cf396bfc402e 100644
--- a/src/main/java/neatlogic/module/cmdb/api/resourcecenter/appmodule/ListAppModuleListForTreeApi.java
+++ b/src/main/java/neatlogic/module/cmdb/api/resourcecenter/appmodule/ListAppModuleListForTreeApi.java
@@ -19,27 +19,19 @@ import com.alibaba.fastjson.JSONObject;
import neatlogic.framework.auth.core.AuthAction;
import neatlogic.framework.cmdb.auth.label.CMDB;
import neatlogic.framework.cmdb.dto.resourcecenter.AppModuleVo;
+import neatlogic.framework.cmdb.resourcecenter.datasource.core.IResourceCenterDataSource;
+import neatlogic.framework.cmdb.resourcecenter.datasource.core.ResourceCenterDataSourceFactory;
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.resourcecenter.ResourceMapper;
-import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Service;
-import javax.annotation.Resource;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
@Service
@AuthAction(action = CMDB.class)
@OperationType(type = OperationTypeEnum.SEARCH)
public class ListAppModuleListForTreeApi extends PrivateApiComponentBase {
- @Resource
- private ResourceMapper resourceMapper;
-
@Override
public String getToken() {
return "resourcecenter/appmodule/list/fortree";
@@ -65,26 +57,7 @@ public class ListAppModuleListForTreeApi extends PrivateApiComponentBase {
@Override
public Object myDoService(JSONObject paramObj) throws Exception {
Long appSystemId = paramObj.getLong("appSystemId");
- List tbodyList = resourceMapper.getAppModuleListByAppSystemId(appSystemId);
- if (CollectionUtils.isNotEmpty(tbodyList)) {
- Map appEnvCountMap = new HashMap<>();
- List