From 73aa2baa34211cfcb74233abab04f0ac0ca5b2a2 Mon Sep 17 00:00:00 2001 From: DongZeLiang <2746733890@qq.com> Date: Thu, 1 Aug 2024 16:27:09 +0800 Subject: [PATCH] =?UTF-8?q?feat():=20=E5=A2=9E=E5=8A=A0=E6=9C=AA=E6=8E=A5?= =?UTF-8?q?=E5=85=A5=E5=AE=A2=E6=88=B7=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cloud-pay-server/pom.xml | 5 ++++ .../OrderPayCustomerController.java | 13 ++++++++++ .../pay/service/OrderPayCustomerService.java | 6 +++++ .../impl/OrderPayCustomerServiceImpl.java | 24 +++++++++++++++++++ 4 files changed, 48 insertions(+) diff --git a/cloud-pay-server/pom.xml b/cloud-pay-server/pom.xml index db7d453..10a6b9a 100644 --- a/cloud-pay-server/pom.xml +++ b/cloud-pay-server/pom.xml @@ -91,6 +91,11 @@ com.muyu cloud-pay-common + + + com.muyu + cloud-common-nacos-remote + diff --git a/cloud-pay-server/src/main/java/com/muyu/cloud/pay/controller/OrderPayCustomerController.java b/cloud-pay-server/src/main/java/com/muyu/cloud/pay/controller/OrderPayCustomerController.java index 18e7a26..c074d85 100644 --- a/cloud-pay-server/src/main/java/com/muyu/cloud/pay/controller/OrderPayCustomerController.java +++ b/cloud-pay-server/src/main/java/com/muyu/cloud/pay/controller/OrderPayCustomerController.java @@ -6,6 +6,7 @@ import com.muyu.cloud.pay.domain.resp.CustomerResp; import com.muyu.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.AllArgsConstructor; import lombok.RequiredArgsConstructor; @@ -47,4 +48,16 @@ public class OrderPayCustomerController { ); } + /** + * 获取所有客户的 + * @return 客户集合 + */ + @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/muyu/cloud/pay/service/OrderPayCustomerService.java b/cloud-pay-server/src/main/java/com/muyu/cloud/pay/service/OrderPayCustomerService.java index 0472326..329e954 100644 --- a/cloud-pay-server/src/main/java/com/muyu/cloud/pay/service/OrderPayCustomerService.java +++ b/cloud-pay-server/src/main/java/com/muyu/cloud/pay/service/OrderPayCustomerService.java @@ -21,4 +21,10 @@ public interface OrderPayCustomerService extends IService { * @return 客户集合 */ public List selectList(CustomerListReq customerListReq); + + /** + * 获取所有的客户 + * @return 客户集合 + */ + List getCustomerAllList (); } diff --git a/cloud-pay-server/src/main/java/com/muyu/cloud/pay/service/impl/OrderPayCustomerServiceImpl.java b/cloud-pay-server/src/main/java/com/muyu/cloud/pay/service/impl/OrderPayCustomerServiceImpl.java index 12f3a3e..4e0efab 100644 --- a/cloud-pay-server/src/main/java/com/muyu/cloud/pay/service/impl/OrderPayCustomerServiceImpl.java +++ b/cloud-pay-server/src/main/java/com/muyu/cloud/pay/service/impl/OrderPayCustomerServiceImpl.java @@ -10,11 +10,14 @@ import com.muyu.cloud.pay.mapper.OrderPayCustomerMapper; import com.muyu.cloud.pay.service.OrderPayCustomerService; import com.muyu.cloud.pay.service.OrderPayService; import com.muyu.common.core.utils.StringUtils; +import com.muyu.common.nacos.service.NacosServerService; import jakarta.annotation.Resource; import lombok.extern.log4j.Log4j2; import org.springframework.stereotype.Service; import java.util.List; +import java.util.Set; +import java.util.stream.Collectors; /** * @Author: DongZeLiang @@ -31,6 +34,9 @@ public class OrderPayCustomerServiceImpl @Resource(type = OrderPayServiceImpl.class) private OrderPayService orderPayService; + @Resource + private NacosServerService nacosServerService; + /** * 查询客户集合 * @@ -65,4 +71,22 @@ public class OrderPayCustomerServiceImpl ) .toList(); } + + /** + * 获取所有的客户 + * + * @return 客户集合 + */ + @Override + public List getCustomerAllList () { + List nacosServerAllList = nacosServerService.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(); + } }