feat():增加nacosService业务类

master
WeiRan 2024-08-08 22:24:53 +08:00
parent 846e983c52
commit ff549fc258
4 changed files with 48 additions and 6 deletions

View File

@ -6,6 +6,7 @@ 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;
/**
@ -24,5 +25,5 @@ public interface NacosServiceRemote {
@GetRequest(
url = "/list"
)
public void serviceList(@Body ServiceListReq serviceListReq);
public ServiceListResp serviceList(@Body ServiceListReq serviceListReq);
}

View File

@ -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;
/**
@ -27,10 +24,13 @@ public class ServiceListReq extends BaseReq{
/**
*
*/
private int pageSize=10;
@Builder.Default
private int pageSize=2;
/**
*
*/
private String pageName;
}

View File

@ -0,0 +1,40 @@
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 org.springframework.beans.factory.annotation.Autowired;
import java.util.ArrayList;
import java.util.List;
/**
* @Authorweiran
* @Packagecom.muyu.common.nacos.service
* @Projectcloud-common-nacos-remote
* @nameNacosServerService
* @Date2024/8/8 22:02
*/
public class NacosServerService {
@Autowired
NacosServiceRemote nacosServiceRemote;
public List<String> nacosServerAllList(){
List<String>serverList = new ArrayList<>();
ServiceListResp serviceListResp=null;
int pageNo=1,pageSize=2;
do {
serviceListResp = nacosServiceRemote.serviceList(
ServiceListReq.builder()
.pageNo(++pageNo)
.pageSize(pageSize)
.build()
);
serverList.addAll(serviceListResp.getDoms());
}while (serviceListResp.getCount() > pageNo * pageSize);
return serverList;
}
}

View File

@ -1 +1,2 @@
com.muyu.common.nacos.remote.interceptor.NacosNamespaceInterceptor
com.muyu.common.nacos.service.NacosServerService