新增nacosService业务层

master
面包骑士 2024-08-09 20:09:25 +08:00
parent e0c3e84335
commit f1e0af2598
7 changed files with 64 additions and 12 deletions

View File

@ -1,10 +1,9 @@
package com.muyu.common.acos.api;
package com.muyu.common.acos.remote;
import com.dtflys.forest.annotation.Address;
import com.dtflys.forest.annotation.BaseRequest;
import com.dtflys.forest.annotation.Body;
import com.muyu.common.acos.domain.req.NacosListReq;
import com.muyu.common.acos.domain.resp.NacoeListResp;
import com.muyu.common.acos.remote.req.NacosListReq;
import com.muyu.common.acos.remote.resp.NacoeListResp;
import com.muyu.common.core.constant.Constants;
import org.springframework.web.bind.annotation.GetMapping;
@ -18,7 +17,7 @@ import org.springframework.web.bind.annotation.GetMapping;
@BaseRequest(
baseURL = Constants.HTTP + "#{nacos.addr}/nacos/v1/ns/service"
)
public interface NacosServiceApi {
public interface NacosServiceRemote {
@GetMapping("/list")
NacoeListResp serviceList(@Body NacosListReq nacosListReq);

View File

@ -1,4 +1,4 @@
package com.muyu.common.acos.interceptor;
package com.muyu.common.acos.remote.interceptor;
/**
* @Author:

View File

@ -1,4 +1,4 @@
package com.muyu.common.acos.domain.req;
package com.muyu.common.acos.remote.req;
import lombok.*;

View File

@ -1,4 +1,4 @@
package com.muyu.common.acos.domain.req;
package com.muyu.common.acos.remote.req;
import lombok.*;
import lombok.experimental.SuperBuilder;
@ -12,8 +12,10 @@ import lombok.experimental.SuperBuilder;
*/
@Data
@ToString
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = true)
@ -25,6 +27,7 @@ public class NacosListReq extends BaseReq{
/**
*
*/
@Builder.Default
private long pageSize = 30;
}

View File

@ -1,7 +1,9 @@
package com.muyu.common.acos.domain.resp;
package com.muyu.common.acos.remote.resp;
import lombok.*;
import java.util.List;
/**
* @Author:
* @Name: NacoeListResp
@ -15,7 +17,7 @@ import lombok.*;
@NoArgsConstructor
@AllArgsConstructor
public class NacoeListResp {
private long count;
private int count;
private String[] doms;
private List<String> doms;
}

View File

@ -0,0 +1,47 @@
package com.muyu.common.acos.service;
/**
* @Author:
* @Name: NacosServerService
* @Description: nacos
* @CreatedDate: 2024/8/9 7:56
* @FilePath: com.muyu.common.acos.service
*/
import com.muyu.common.acos.remote.NacosServiceRemote;
import com.muyu.common.acos.remote.req.NacosListReq;
import com.muyu.common.acos.remote.resp.NacoeListResp;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/**
* @Author:
* @Name: NacosServerService
* @Description: nacos
* @CreatedDate: 2024/8/9 7:56
* @FilePath: com.muyu.common.acos.service
*/
public class NacosServerService {
@Resource
private NacosServiceRemote nacosServiceRemote;
public List<String> getServerListAll(){
ArrayList<String> serverList = new ArrayList<>();
NacoeListResp nacoeListResp = null;
int pageNo = 0, pageSize = 30;
do{
nacoeListResp = nacosServiceRemote.serviceList(
NacosListReq.builder()
.pageNo(++pageNo)
.pageSize(pageSize)
.build());
serverList.addAll(nacoeListResp.getDoms());
}while (nacoeListResp.getCount() > pageNo * pageSize );
return serverList;
}
}

View File

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