diff --git a/.idea/misc.xml b/.idea/misc.xml index 59b222f..60003b0 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -8,14 +8,8 @@ - diff --git a/cloud-pay-server/pom.xml b/cloud-pay-server/pom.xml index 8aaa7ca..df4c0ad 100644 --- a/cloud-pay-server/pom.xml +++ b/cloud-pay-server/pom.xml @@ -18,11 +18,21 @@ + com.muyu cloud-pay-common + + + com.muyu + cloud-common-nacos-remote + 1.0.0 + + + + com.alibaba.cloud 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 b9b47d8..e226876 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 @@ -5,14 +5,12 @@ 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.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; @@ -39,4 +37,17 @@ public class OrderPayCustomerController { orderPayCustomerService.selectList(customerListReq) ); } + + /*** + * 获取所有客户的列表 + * @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 1526af0..ed2ff5f 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 @@ -14,4 +14,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 89ee1c6..c2f2205 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,10 +10,13 @@ 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 org.springframework.stereotype.Service; import javax.annotation.Resource; import java.util.List; +import java.util.Set; +import java.util.stream.Collectors; @Service public class OrderPayCustomerServiceImpl extends @@ -22,6 +25,10 @@ public class OrderPayCustomerServiceImpl extends @Resource(type = OrderPayServiceImpl.class) private OrderPayService orderPayService; + @Resource + private NacosServerService nacosServerService; + + @Override public List selectList(CustomerListReq customerListReq) { @@ -52,4 +59,21 @@ public class OrderPayCustomerServiceImpl extends .toList())).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(); + } }