fix():修复forest请求naocsApi接口因为路径参数的问题

master
WeiRan 2024-08-09 14:21:35 +08:00
parent d2e48b9f06
commit 477a191ac8
1 changed files with 6 additions and 1 deletions

View File

@ -1,8 +1,10 @@
package com.muyu.common.nacos.service; package com.muyu.common.nacos.service;
import com.alibaba.fastjson2.JSONObject;
import com.muyu.common.nacos.remote.NacosServiceRemote; import com.muyu.common.nacos.remote.NacosServiceRemote;
import com.muyu.common.nacos.remote.req.ServiceListReq; import com.muyu.common.nacos.remote.req.ServiceListReq;
import com.muyu.common.nacos.remote.resp.ServiceListResp; import com.muyu.common.nacos.remote.resp.ServiceListResp;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import java.util.ArrayList; import java.util.ArrayList;
@ -15,6 +17,7 @@ import java.util.List;
* @nameNacosServerService * @nameNacosServerService
* @Date2024/8/8 22:02 * @Date2024/8/8 22:02
*/ */
@Log4j2
public class NacosServerService { public class NacosServerService {
@Autowired @Autowired
NacosServiceRemote nacosServiceRemote; NacosServiceRemote nacosServiceRemote;
@ -25,7 +28,7 @@ public class NacosServerService {
public List<String> nacosServerAllList(){ public List<String> nacosServerAllList(){
List<String>serverList = new ArrayList<>(); List<String>serverList = new ArrayList<>();
ServiceListResp serviceListResp=null; ServiceListResp serviceListResp=null;
int pageNo=1,pageSize=2; int pageNo=0,pageSize=2;
do { do {
serviceListResp = nacosServiceRemote.serviceList( serviceListResp = nacosServiceRemote.serviceList(
ServiceListReq.builder() ServiceListReq.builder()
@ -34,7 +37,9 @@ public class NacosServerService {
.build() .build()
); );
serverList.addAll(serviceListResp.getDoms()); serverList.addAll(serviceListResp.getDoms());
log.info("添加serverList数据为[ {} ] ", JSONObject.toJSONString(serviceListResp.getDoms()));
}while (serviceListResp.getCount() > pageNo * pageSize); }while (serviceListResp.getCount() > pageNo * pageSize);
log.info("获取数据为:{}", JSONObject.toJSONString(serverList));
return serverList; return serverList;
} }
} }