master
parent
9cb3ffe812
commit
aa920fc0e3
|
@ -0,0 +1,16 @@
|
|||
package com.muyu.common.nacos;
|
||||
|
||||
import com.dtflys.forest.springboot.annotation.ForestScan;
|
||||
import com.muyu.common.nacos.remote.interceptor.NacosNamespaceInterceptor;
|
||||
import com.muyu.common.nacos.service.NacosServerService;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Import;
|
||||
|
||||
@Configuration
|
||||
@ForestScan(basePackages = "com.muyu.common.nacos.remote")
|
||||
@Import(value = {
|
||||
NacosNamespaceInterceptor.class,
|
||||
NacosServerService.class
|
||||
})
|
||||
public class NacosRemoteConfig {
|
||||
}
|
|
@ -13,11 +13,9 @@ import com.muyu.common.nacos.remote.resp.ServiceListResp;
|
|||
baseURL = Constants.HTTP+"#{nacos.addr}/nacos/v1/ns/service",
|
||||
interceptor = {NacosNamespaceInterceptor.class}
|
||||
)
|
||||
public class NacosServiceRemote {
|
||||
public interface NacosServiceRemote {
|
||||
@GetRequest(
|
||||
url = "/list"
|
||||
)
|
||||
public ServiceListResp serviceList(@Body ServiceListReq req){
|
||||
return null;
|
||||
}
|
||||
public ServiceListResp serviceList(@Body ServiceListReq req);
|
||||
}
|
||||
|
|
|
@ -1,9 +1,6 @@
|
|||
package com.muyu.common.nacos.remote.req;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.*;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
@Data
|
||||
|
@ -13,6 +10,7 @@ import lombok.experimental.SuperBuilder;
|
|||
@EqualsAndHashCode(callSuper = true)
|
||||
public class ServiceListReq extends BaseReq{
|
||||
private int pageNum;
|
||||
@Builder.Default
|
||||
private int pageSize = 10;
|
||||
private String groupName;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
package com.muyu.common.nacos.service;
|
||||
|
||||
|
||||
import com.muyu.common.nacos.remote.NacosServiceRemote;
|
||||
import com.muyu.common.nacos.remote.req.ServiceListReq;
|
||||
import com.muyu.common.nacos.remote.resp.ServiceListResp;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class NacosServerService {
|
||||
|
||||
|
||||
@Resource
|
||||
private NacosServiceRemote nacosServiceRemote;
|
||||
|
||||
|
||||
public List<String> nacosServerAllList() {
|
||||
List<String> serverList = new ArrayList<>();
|
||||
ServiceListResp serviceListResp = null;
|
||||
int pageNum =1,pageSize=2;
|
||||
do {
|
||||
serviceListResp = nacosServiceRemote.serviceList(
|
||||
ServiceListReq.builder()
|
||||
.pageNum(++pageNum)
|
||||
.pageSize(pageSize)
|
||||
.build()
|
||||
);
|
||||
serverList.addAll(serviceListResp.getDoms());
|
||||
} while (serviceListResp.getCount()>pageNum* pageSize );
|
||||
return serverList;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1 +1 @@
|
|||
com.muyu.common.nacos.remote.interceptor.NacosNamespaceInterceptor
|
||||
com.muyu.common.nacos.NacosRemoteConfig
|
||||
|
|
Loading…
Reference in New Issue