修复nacos请求参数问题

master
lwj 2024-08-08 20:00:02 +08:00
parent c653ddf102
commit ddaaf09f85
5 changed files with 7 additions and 2 deletions

View File

@ -27,6 +27,8 @@
<artifactId>cloud-common-core</artifactId>
</dependency>
</dependencies>

View File

@ -12,5 +12,6 @@ import org.springframework.context.annotation.Import;
NacosNamespaceInterceptor.class,
NacosServerService.class
})
public class NacosRemoteConfig {
}

View File

@ -4,6 +4,7 @@ package com.muyu.common.nacos.remote;
import com.dtflys.forest.annotation.BaseRequest;
import com.dtflys.forest.annotation.Body;
import com.dtflys.forest.annotation.GetRequest;
import com.dtflys.forest.annotation.Query;
import com.muyu.common.core.constant.Constants;
import com.muyu.common.nacos.remote.interceptor.NacosNamespaceInterceptor;
import com.muyu.common.nacos.remote.req.ServiceListReq;
@ -20,5 +21,5 @@ public interface NacosServiceReomte {
)
public ServiceListResp serviceList(@Body ServiceListReq serviceListReq);
public ServiceListResp serviceList(@Query ServiceListReq serviceListReq);
}

View File

@ -23,7 +23,7 @@ public class NacosNamespaceInterceptor<T> implements Interceptor<T> {
public boolean beforeExecute(ForestRequest req) {
if(StringUtils.isNotEmpty(namespaceId)){
// 执行在发送请求之前处理的代码
Object reqNamespaceId = req.getQuery("namespaceId");
Object reqNamespaceId =Convert.utf8Str( req.getQuery("namespaceId"));
if(reqNamespaceId==null){
log.warn("本次请求nacos的namespaceId未携带已添加[{}]",namespaceId);
req.addQuery("namespaceId", namespaceId); // 添加URL的Query参数

View File

@ -25,6 +25,7 @@ public class NacosServerService {
.build()
);
serverList.addAll(serviceListResp.getDoms());
}while (serviceListResp.getCount() > pageNo*pageSize);
return serverList;