From 627c5c6622c3a9b1b3f98735d38b1fdac481027e Mon Sep 17 00:00:00 2001
From: LQS <2506203757@qq.com>
Date: Wed, 7 Aug 2024 11:28:09 +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 | 6 +++++
.../OrderPayCustomerController.java | 20 ++++++++++++---
.../pay/service/OrderPayCustomerService.java | 6 ++++-
.../impl/OrderPayCustomerServiceImpl.java | 25 +++++++++++++++++++
4 files changed, 52 insertions(+), 5 deletions(-)
diff --git a/cloud-pay-server/pom.xml b/cloud-pay-server/pom.xml
index 571aeef..c9fdd26 100644
--- a/cloud-pay-server/pom.xml
+++ b/cloud-pay-server/pom.xml
@@ -92,6 +92,12 @@
cloud-pay-common
+
+ com.muyu
+ cloud-common-nacos-remote
+ 1.0.0
+
+
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 a3ae59f..b35855a 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
@@ -7,15 +7,14 @@ 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.RequiredArgsConstructor;
import lombok.extern.log4j.Log4j2;
import org.springframework.stereotype.Controller;
+import org.springframework.stereotype.Service;
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;
@@ -47,4 +46,17 @@ public class OrderPayCustomerController {
); //客户lei
}
+ /**
+ * 获取所有客户的列表
+ * @return 客户集合
+ */
+ @GetMapping("/all")
+ @Operation(summary = "获取未接入的客户" , description = "调用nacosAPI获取所有的微服务名称,作为支付中台的客户")
+ @Schema(description = "获取未接入的客户",defaultValue = "[\"客户1\",\"客户1\"]",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 a06587e..1ac6285 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
@@ -17,5 +17,9 @@ public interface OrderPayCustomerService extends IService {
*/
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 c23f9c5..36b9a17 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,12 +10,15 @@ import com.muyu.cloud.pay.domain.resp.CustomerResp;
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.nacos.service.NacosServerService;
import lombok.extern.log4j.Log4j2;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
+import java.util.Set;
+import java.util.stream.Collectors;
@Log4j2
@Service
@@ -26,6 +29,10 @@ public class OrderPayCustomerServiceImpl
@Resource(type = OrderPayServiceImpl.class)
private OrderPayService orderPayService;
+ @Resource
+ private NacosServerService nacosServerService;
+
+
@Override //查询客户集合
public List selectList(CustomerListReq customerListReq) {
LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>();
@@ -102,4 +109,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()
+ ;
+ }
}