diff --git a/cloud-pay-server/pom.xml b/cloud-pay-server/pom.xml index bc0b3db..0981817 100644 --- a/cloud-pay-server/pom.xml +++ b/cloud-pay-server/pom.xml @@ -19,6 +19,11 @@ + + com.bwie + cloud-common-nacos-remote + + com.alibaba.cloud diff --git a/cloud-pay-server/src/main/java/com/bwie/cloud/pay/controller/OrderPayCustomerController.java b/cloud-pay-server/src/main/java/com/bwie/cloud/pay/controller/OrderPayCustomerController.java index 4abfbb9..81ddbd5 100644 --- a/cloud-pay-server/src/main/java/com/bwie/cloud/pay/controller/OrderPayCustomerController.java +++ b/cloud-pay-server/src/main/java/com/bwie/cloud/pay/controller/OrderPayCustomerController.java @@ -6,14 +6,12 @@ import com.bwie.cloud.pay.domain.resp.CustomerResp; import com.bwie.cloud.pay.service.OrderPayCustomerService; import com.muyu.common.core.domain.Result; import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.tags.Tag; import lombok.RequiredArgsConstructor; import lombok.extern.log4j.Log4j2; import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import java.util.List; @@ -45,4 +43,14 @@ public class OrderPayCustomerController { return Result.success(orderPayCustomerService.selectList(customerListReq)); } + + @GetMapping("/all") + @Operation(summary = "获取未接入的客户",description = "调用nacosAPI获取所有的微服务,作为支付中台的客户") + @Schema(description = "获取未接入的客户",defaultValue = "[\"客户1\"],[\"客户2\"]",type = "List") + public Result> getCustomerAllList(){ + return Result.success( + orderPayCustomerService.getCustomerAllList() + ); + } + } diff --git a/cloud-pay-server/src/main/java/com/bwie/cloud/pay/service/OrderPayCustomerService.java b/cloud-pay-server/src/main/java/com/bwie/cloud/pay/service/OrderPayCustomerService.java index c645ec4..510b57e 100644 --- a/cloud-pay-server/src/main/java/com/bwie/cloud/pay/service/OrderPayCustomerService.java +++ b/cloud-pay-server/src/main/java/com/bwie/cloud/pay/service/OrderPayCustomerService.java @@ -21,4 +21,6 @@ public interface OrderPayCustomerService extends IService { * @return */ public List selectList(CustomerListReq customerListReq); + + List getCustomerAllList(); } diff --git a/cloud-pay-server/src/main/java/com/bwie/cloud/pay/service/impl/OrderPayCustomerServiceImpl.java b/cloud-pay-server/src/main/java/com/bwie/cloud/pay/service/impl/OrderPayCustomerServiceImpl.java index 02fe86e..09208cf 100644 --- a/cloud-pay-server/src/main/java/com/bwie/cloud/pay/service/impl/OrderPayCustomerServiceImpl.java +++ b/cloud-pay-server/src/main/java/com/bwie/cloud/pay/service/impl/OrderPayCustomerServiceImpl.java @@ -10,6 +10,7 @@ import com.bwie.cloud.pay.domain.resp.CustomerResp; import com.bwie.cloud.pay.mapper.OrderPayCustomerMapper; import com.bwie.cloud.pay.service.OrderPayCustomerService; import com.bwie.cloud.pay.service.OrderPayService; +import com.bwie.nacos.remote.service.NacosServeService; import com.muyu.common.core.domain.Result; import lombok.extern.log4j.Log4j2; import org.apache.commons.lang3.StringUtils; @@ -18,7 +19,9 @@ import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.util.ArrayList; import java.util.List; +import java.util.Set; import java.util.function.Function; +import java.util.stream.Collectors; /** * @Author:zhangzhihao @@ -33,6 +36,9 @@ public class OrderPayCustomerServiceImpl implements OrderPayCustomerService { + @Resource + private NacosServeService nacosServeService; + @Resource(type = OrderPayServiceImpl.class) private OrderPayService orderPayService; @@ -66,5 +72,20 @@ public class OrderPayCustomerServiceImpl .toList(); } + @Override + public List getCustomerAllList() { + List nacosServerAllList = nacosServeService.nacosServerAllList(); + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + + queryWrapper.select(OrderPayCustomer::getAppCode); + List orderPayCustomerList = this.list(queryWrapper); + Set customerSet = orderPayCustomerList.stream() + .map(OrderPayCustomer::getAppCode).collect(Collectors.toSet()); + + return nacosServerAllList.stream() + .filter(nacosServer ->!customerSet.contains(nacosServer)) + .toList(); + } + }