diff --git a/ms/register-center1/src/main/java/com/micro/fast/eureka/server/controller/RestfulEurekaController.java b/ms/register-center1/src/main/java/com/micro/fast/eureka/server/controller/RestfulEurekaController.java index ca229b6..bd46faa 100644 --- a/ms/register-center1/src/main/java/com/micro/fast/eureka/server/controller/RestfulEurekaController.java +++ b/ms/register-center1/src/main/java/com/micro/fast/eureka/server/controller/RestfulEurekaController.java @@ -54,6 +54,13 @@ public class RestfulEurekaController { return ServerResponse.successMsgData("获取所有实例成功", map); } + @GetMapping("/appsInfo") + @ApiOperation("获取所有的服务实例的详细信息") + public ServerResponse appsInfos() { + List sortedApplications = getRegistry().getSortedApplications(); + return ServerResponse.successMsgData("获取所有实例成功", sortedApplications); + } + @GetMapping("/apps/{id}") @ApiOperation("根据id获取实例的信息,模糊查询") public ServerResponse getInstance(@PathVariable("id") String instanceId) { @@ -76,24 +83,20 @@ public class RestfulEurekaController { } @GetMapping("/apps/cluster/{appName}") - @ApiOperation("根据appId,也就是application.name查询实例,可能有多个") + @ApiOperation("根据appName,也就是application.name查询实例,模糊查询") public ServerResponse getInstancesByAppId(@PathVariable("appName") String appName) { - Set instanceInfos = new HashSet<>(10); + List instanceInfos = new LinkedList<>(); if (StringUtils.isNotBlank(appName)){ List sortedApplications = getRegistry().getSortedApplications(); for (Application sortedApplication : sortedApplications) { - List instances = sortedApplication.getInstances(); - for (InstanceInfo instance : instances) { - if (StringUtils.equalsIgnoreCase(instance.getAppName(),appName)){ - instanceInfos.add(instance); - } + if (sortedApplication.getName().contains(appName)){ + instanceInfos.add(sortedApplication); } - } }else { - return ServerResponse.errorMsg("instanceId不能为空"); + return ServerResponse.errorMsg("appName不能为空"); } - return ServerResponse.successMsgData("根据主机名获取实例信息成功", instanceInfos); + return ServerResponse.successMsgData("根据appName获取实例信息成功", instanceInfos); } @GetMapping("/apps/app/{appName}/{id}") @@ -124,7 +127,7 @@ public class RestfulEurekaController { } /** - * 调整服务的状态,可以用于在无感知的情况下热部署服务 + * 调整服务的状态,可以用于在不影响业务的情况下热部署服务 * @param appName * @param id * @param status