From fbc72f0defaab11944c684236bd8f562508e22bf Mon Sep 17 00:00:00 2001 From: nkorange Date: Tue, 4 Jun 2019 15:03:05 +0800 Subject: [PATCH] Close #1319 --- .../naming/controllers/CatalogController.java | 26 ++++++++++--------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/naming/src/main/java/com/alibaba/nacos/naming/controllers/CatalogController.java b/naming/src/main/java/com/alibaba/nacos/naming/controllers/CatalogController.java index 0a5fe9769..f75a436e6 100644 --- a/naming/src/main/java/com/alibaba/nacos/naming/controllers/CatalogController.java +++ b/naming/src/main/java/com/alibaba/nacos/naming/controllers/CatalogController.java @@ -148,22 +148,24 @@ public class CatalogController { String namespaceId = WebUtils.optional(request, CommonParams.NAMESPACE_ID, Constants.DEFAULT_NAMESPACE_ID); List serviceDetailInfoList = new ArrayList<>(); + int pageNo = Integer.parseInt(WebUtils.required(request, "pageNo")); + int pageSize = Integer.parseInt(WebUtils.required(request, "pageSize")); + String keyword = WebUtils.optional(request, "keyword", StringUtils.EMPTY); - serviceManager - .getServiceMap(namespaceId) - .forEach( - (serviceName, service) -> { + List serviceList = new ArrayList<>(8); + serviceManager.getPagedService(namespaceId, pageNo, pageSize, keyword, StringUtils.EMPTY, serviceList); - ServiceDetailInfo serviceDetailInfo = new ServiceDetailInfo(); - serviceDetailInfo.setServiceName(NamingUtils.getServiceName(serviceName)); - serviceDetailInfo.setGroupName(NamingUtils.getGroupName(serviceName)); - serviceDetailInfo.setMetadata(service.getMetadata()); + for (Service service : serviceList) { + ServiceDetailInfo serviceDetailInfo = new ServiceDetailInfo(); + serviceDetailInfo.setServiceName(NamingUtils.getServiceName(service.getName())); + serviceDetailInfo.setGroupName(NamingUtils.getGroupName(service.getName())); + serviceDetailInfo.setMetadata(service.getMetadata()); - Map clusterInfoMap = getStringClusterInfoMap(service); - serviceDetailInfo.setClusterMap(clusterInfoMap); + Map clusterInfoMap = getStringClusterInfoMap(service); + serviceDetailInfo.setClusterMap(clusterInfoMap); - serviceDetailInfoList.add(serviceDetailInfo); - }); + serviceDetailInfoList.add(serviceDetailInfo); + } return serviceDetailInfoList; } else {