feat():增加nacosService接口
parent
62db6932f2
commit
40f386e011
|
@ -6,6 +6,9 @@ import com.dtflys.forest.annotation.GetRequest;
|
|||
import com.muyu.common.core.constant.Constants;
|
||||
import com.muyu.common.nacos.remote.interceptor.NacosNamespaceInterceptor;
|
||||
import com.muyu.common.nacos.remote.req.ServiceListReq;
|
||||
import com.muyu.common.nacos.remote.resp.ServiceListResp;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author:yang
|
||||
|
@ -23,5 +26,5 @@ public interface NacosServiceRemote {
|
|||
@GetRequest(
|
||||
url = "/list"
|
||||
)
|
||||
public void serviceList(@Body ServiceListReq serviceListReq);
|
||||
public ServiceListResp serviceList(@Body ServiceListReq serviceListReq);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
||||
/**
|
||||
|
@ -28,7 +25,8 @@ public class ServiceListReq extends BaseReq{
|
|||
/**
|
||||
* 分页大小
|
||||
*/
|
||||
private int pageSize = 10;
|
||||
@Builder.Default
|
||||
private int pageSize = 2;
|
||||
|
||||
/**
|
||||
* 分组名
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
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;
|
||||
|
||||
/**
|
||||
* @Author:yang
|
||||
* @Package:com.muyu.common.nacos.service
|
||||
* @Project:cloud-common-nacos-remote
|
||||
* @name:NacosServiceService
|
||||
* @Date:2024/8/9 20:08
|
||||
*/
|
||||
public class NacosServiceService {
|
||||
|
||||
@Resource
|
||||
private NacosServiceRemote nacosServiceRemote;
|
||||
|
||||
public List<String > nacosServerAllList(){
|
||||
List<String> serverList = new ArrayList<>();
|
||||
ServiceListResp serviceListResp = null;
|
||||
int pageNo = 0 , pageSize = 2;
|
||||
do{
|
||||
serviceListResp = nacosServiceRemote.serviceList(
|
||||
ServiceListReq.builder()
|
||||
.pageNo(++pageNo)
|
||||
.pageSize(pageSize)
|
||||
.build()
|
||||
);
|
||||
serverList.addAll(serviceListResp.getDoms());
|
||||
}while (serviceListResp.getCount() > pageNo * pageSize);
|
||||
return serverList;
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue