Skip to content

Commit

Permalink
feat($AuthCenter): get services info
Browse files Browse the repository at this point in the history
  • Loading branch information
Johnny Miller (锺俊) committed Dec 25, 2020
1 parent f54ee9b commit 97aadce
Showing 1 changed file with 27 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
package com.jmsoftware.maf.authcenter.permission.controller;

import com.jmsoftware.maf.authcenter.permission.service.PermissionService;
import com.jmsoftware.maf.common.bean.ResponseBodyBean;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.RequestMapping;
import lombok.extern.slf4j.Slf4j;
import lombok.val;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.LinkedHashMap;
import java.util.List;

/**
* <h1>PermissionController</h1>
* <p>
Expand All @@ -13,8 +22,25 @@
* @author Johnny Miller (锺俊), e-mail: johnnysviva@outlook.com
* @date 5/11/20 8:34 AM
*/
@Slf4j
@RestController
@RequiredArgsConstructor
@Api(tags = {"Permission API"})
public class PermissionController {
private final PermissionService permissionService;
private final DiscoveryClient discoveryClient;

@GetMapping("/permissions/services-info")
@ApiOperation(value = "Get services info", notes = "Get services info")
public ResponseBodyBean<?> servicesInfo() {
List<String> services = discoveryClient.getServices();
log.info("Service ID: {}", services);
val resultMap = new LinkedHashMap<String, Object>();
services.forEach(service -> {
val instances = discoveryClient.getInstances(service);
log.info("Instances: {}", instances);
resultMap.put(service, instances);
});
return ResponseBodyBean.ofSuccess(resultMap);
}
}

0 comments on commit 97aadce

Please sign in to comment.