36 lines
1.0 KiB
Java
36 lines
1.0 KiB
Java
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 lombok.extern.log4j.Log4j2;
|
|
|
|
import javax.annotation.Resource;
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
|
|
@Log4j2
|
|
public class NacosServerService {
|
|
|
|
@Resource
|
|
private NacosServiceRemote nacosServiceRemote;
|
|
|
|
public List<String> nacosServiceAllList(){
|
|
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;
|
|
}
|
|
|
|
}
|