feat():增加nacosService业务类
parent
be7effd84f
commit
af5b4ef993
|
@ -1,6 +1,5 @@
|
||||||
package com.muyu.common.nacos.remote;
|
package com.muyu.common.nacos.remote;
|
||||||
|
|
||||||
import com.dtflys.forest.annotation.Address;
|
|
||||||
import com.dtflys.forest.annotation.BaseRequest;
|
import com.dtflys.forest.annotation.BaseRequest;
|
||||||
import com.dtflys.forest.annotation.Body;
|
import com.dtflys.forest.annotation.Body;
|
||||||
import com.dtflys.forest.annotation.GetRequest;
|
import com.dtflys.forest.annotation.GetRequest;
|
||||||
|
|
|
@ -1,10 +1,7 @@
|
||||||
package com.muyu.common.nacos.remote.req;
|
package com.muyu.common.nacos.remote.req;
|
||||||
|
|
||||||
import com.dtflys.forest.annotation.BaseRequest;
|
import com.dtflys.forest.annotation.BaseRequest;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.*;
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
import lombok.experimental.SuperBuilder;
|
import lombok.experimental.SuperBuilder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -30,7 +27,8 @@ public class ServiceListReq extends BaseReq{
|
||||||
/**
|
/**
|
||||||
* 分页大小
|
* 分页大小
|
||||||
*/
|
*/
|
||||||
private int pageSize=10;
|
@Builder.Default
|
||||||
|
private int pageSize=2;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 分组名
|
* 分组名
|
||||||
|
|
|
@ -0,0 +1,54 @@
|
||||||
|
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:liuxinyue
|
||||||
|
* @Package:com.muyu.common.nacos.remote.service
|
||||||
|
* @Project:cloud-common-nacos-remote
|
||||||
|
* @name:NacosServic
|
||||||
|
* @Date:2024/8/7 22:15
|
||||||
|
*/
|
||||||
|
public class NacosServiceService {
|
||||||
|
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private NacosServiceRemote nacosServiceRemote;
|
||||||
|
|
||||||
|
public List<String> nacosServerAllList(){
|
||||||
|
|
||||||
|
List<String> serverList = new ArrayList<String>();
|
||||||
|
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;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1 +1,2 @@
|
||||||
com.muyu.common.nacos.remote.interceptor.NacosNamespaceInterceptor
|
com.muyu.common.nacos.remote.interceptor.NacosNamespaceInterceptor
|
||||||
|
com.muyu.common.nacos.service.NacosServiceService
|
Loading…
Reference in New Issue