From 034cb9a0f4c98f47c520586ab157ead53e289cde Mon Sep 17 00:00:00 2001
From: WeiRan <2392355487@qq.com>
Date: Fri, 9 Aug 2024 00:11:27 +0800
Subject: [PATCH] =?UTF-8?q?feat():=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 | 19 +++++++++++----
.../pay/service/OrderPayCustomerService.java | 6 +++++
.../impl/OrderPayCustomerServiceImpl.java | 24 +++++++++++++++++++
4 files changed, 50 insertions(+), 4 deletions(-)
diff --git a/cloud-pay-server/pom.xml b/cloud-pay-server/pom.xml
index 473047b..f389e20 100644
--- a/cloud-pay-server/pom.xml
+++ b/cloud-pay-server/pom.xml
@@ -90,6 +90,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 4635b3d..6c82b8e 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,14 +6,12 @@ import com.muyu.cloud.pay.domin.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.RequiredArgsConstructor;
import lombok.extern.log4j.Log4j2;
import org.springframework.validation.annotation.Validated;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
import java.util.List;
@@ -49,5 +47,18 @@ public class OrderPayCustomerController {
}
+ /**
+ * 获取所有客户的列表
+ * @return
+ */
+ @GetMapping("/all")
+ @Operation(summary = "获取未接入的客户",description = "调用nacosAPI获取有的微服务名称,作为支付中台的客户")
+ @Schema(description = "客户列表",defaultValue = "[\"客户1\",\"客户2\"]",type = "Long")
+ 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 0844518..f8e1cb0 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
@@ -22,4 +22,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 8d2f1d5..7bb68eb 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
@@ -12,6 +12,7 @@ import com.muyu.cloud.pay.service.OrderPayCustomerService;
import com.muyu.cloud.pay.service.OrderPayService;
import com.muyu.common.core.enums.SysPayType;
import com.muyu.common.core.utils.StringUtils;
+import com.muyu.common.nacos.service.NacosServerService;
import io.jsonwebtoken.lang.Strings;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
@@ -19,7 +20,9 @@ import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
+import java.util.Set;
import java.util.function.Function;
+import java.util.stream.Collectors;
/**
* @Author:weiran
@@ -34,6 +37,8 @@ public class OrderPayCustomerServiceImpl extends ServiceImpl selectList(CustomerListReq customerListReq) {
@@ -57,4 +62,23 @@ public class OrderPayCustomerServiceImpl extends ServiceImpl 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();
+
+ }
}