From f40c40a49c9519e9e114f404521580dbbb1d3c5b Mon Sep 17 00:00:00 2001 From: "1437892690@qq.com" <1437892690@qq.com> Date: Wed, 25 Dec 2024 10:31:32 +0800 Subject: [PATCH] =?UTF-8?q?[=E5=8A=9F=E8=83=BD]=20=E8=87=AA=E5=AE=9A?= =?UTF-8?q?=E4=B9=89=E8=A7=86=E5=9B=BE=E6=B7=BB=E5=8A=A0=E5=BC=95=E7=94=A8?= =?UTF-8?q?=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 关联 #[1318860777553920]自定义视图添加引用列表 http://192.168.0.96:8090/demo/rdm.html#/task-detail/939050947543040/939050947543050/1318860777553920 --- .../customview/SearchPublicCustomViewApi.java | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/main/java/neatlogic/module/cmdb/api/customview/SearchPublicCustomViewApi.java b/src/main/java/neatlogic/module/cmdb/api/customview/SearchPublicCustomViewApi.java index 03f24da9..5c4d0d27 100644 --- a/src/main/java/neatlogic/module/cmdb/api/customview/SearchPublicCustomViewApi.java +++ b/src/main/java/neatlogic/module/cmdb/api/customview/SearchPublicCustomViewApi.java @@ -30,6 +30,7 @@ import neatlogic.framework.restful.constvalue.OperationTypeEnum; import neatlogic.framework.restful.core.privateapi.PrivateApiComponentBase; import neatlogic.framework.util.TableResultUtil; import neatlogic.module.cmdb.service.customview.CustomViewService; +import org.apache.commons.collections4.CollectionUtils; import org.springframework.stereotype.Service; import javax.annotation.Resource; @@ -76,14 +77,16 @@ public class SearchPublicCustomViewApi extends PrivateApiComponentBase { CustomViewVo customViewVo = JSON.toJavaObject(paramObj, CustomViewVo.class); customViewVo.setType(CustomViewType.PUBLIC.getValue()); List viewList = customViewService.searchCustomView(customViewVo); - List idList = viewList.stream().map(CustomViewVo::getId).collect(Collectors.toList()); - Map countMap = DependencyManager.getBatchDependencyCount(CmdbFromType.CMDBCUSTOMVIEW, idList); - for (CustomViewVo customView : viewList) { - Integer count = countMap.get(customView.getId()); - if (count == null) { - count = 0; + if (CollectionUtils.isNotEmpty(viewList)) { + List idList = viewList.stream().map(CustomViewVo::getId).collect(Collectors.toList()); + Map countMap = DependencyManager.getBatchDependencyCount(CmdbFromType.CMDBCUSTOMVIEW, idList); + for (CustomViewVo customView : viewList) { + Integer count = countMap.get(customView.getId()); + if (count == null) { + count = 0; + } + customView.setReferenceCount(count); } - customView.setReferenceCount(count); } return TableResultUtil.getResult(viewList, customViewVo); } -- Gitee