diff --git a/cloud-pay-common/src/main/java/com/muyu/cloud/domain/OrderPayCustomer.java b/cloud-pay-common/src/main/java/com/muyu/cloud/domain/OrderPayCustomer.java index ac7b03f..68f589b 100644 --- a/cloud-pay-common/src/main/java/com/muyu/cloud/domain/OrderPayCustomer.java +++ b/cloud-pay-common/src/main/java/com/muyu/cloud/domain/OrderPayCustomer.java @@ -3,6 +3,7 @@ package com.muyu.cloud.domain; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; +import com.muyu.cloud.domain.req.OrderCustomerAddReq; import com.muyu.common.core.web.domain.BaseEntity; import lombok.*; import lombok.experimental.SuperBuilder; @@ -38,8 +39,23 @@ public class OrderPayCustomer extends BaseEntity { */ private String appCode; + /** + * 服务/客户编码 + */ + private String appDesc; + /** * 状态 */ private String status; + + public static OrderPayCustomer addBuild(OrderCustomerAddReq req){ + return OrderPayCustomer.builder() + .appName(req.getAppName()) + .appCode(req.getAppCode()) + .appDesc(req.getAppDesc()) + .status(req.getStatus()) + .remark(req.getRemark()) + .build(); + } } diff --git a/cloud-pay-common/src/main/java/com/muyu/cloud/domain/req/OrderCustomerAddReq.java b/cloud-pay-common/src/main/java/com/muyu/cloud/domain/req/OrderCustomerAddReq.java new file mode 100644 index 0000000..99dcf57 --- /dev/null +++ b/cloud-pay-common/src/main/java/com/muyu/cloud/domain/req/OrderCustomerAddReq.java @@ -0,0 +1,63 @@ +package com.muyu.cloud.domain.req; + +import com.muyu.common.core.validation.custom.IsSystemYesNo; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotEmpty; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @Author:LiDongJia + * @Package:com.muyu.cloud.domain.req + * @Project:cloud-pay + * @name:OrderCustomerAddReq + * @Date:2024/8/10 16:01 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@Tag(name = "支付服务客户添加请求对象", description = "根据入参进行客户服务的添加") +public class OrderCustomerAddReq { + + /** + * 服务/客户名称 + */ + @NotEmpty(message = "服务客户名称不可为空") + @Schema(title = "服务/客户名称", type = "String", defaultValue = "会员服务", + description = "客户名称一般为微服务的中文名称,方便使用者进行区分", requiredProperties = {"appName"}) + private String appName; + + /** + * 服务/客户编码 + */ + @NotBlank(message = "服务客户编码不可为空") + @Schema(title = "服务/客户编码", type = "String", defaultValue = "muyu-vip", + description = "客户编码,从[/customer/all]接口当中进行获取", requiredProperties = {"appName"}) + private String appCode; + + /** + * 服务/客户描述 + */ + @Schema(title = "服务/客户描述", type = "String") + private String appDesc; + + /** + * 状态 + */ + @NotBlank(message = "客户使用状态不可为空") + @IsSystemYesNo + @Schema(title = "服务/客户开通状态", type = "String", defaultValue = "Y", + description = "状态为Y和N, 如果为Y则客户可以适应支付接口, 若为N则客户不可以使用支付类接口") + private String status; + + /** + * 客户备注 + */ + @Schema(title = "服务/客户备注", type = "String") + private String remark; +} diff --git a/cloud-pay-server/src/main/java/com/muyu/cloud/pay/MuYuPayApplication.java b/cloud-pay-server/src/main/java/com/muyu/cloud/pay/MuYuPayApplication.java index 0654146..2012754 100644 --- a/cloud-pay-server/src/main/java/com/muyu/cloud/pay/MuYuPayApplication.java +++ b/cloud-pay-server/src/main/java/com/muyu/cloud/pay/MuYuPayApplication.java @@ -21,9 +21,5 @@ import org.springframework.context.ConfigurableApplicationContext; public class MuYuPayApplication { public static void main(String[] args) { ConfigurableApplicationContext applicationContext = SpringApplication.run(MuYuPayApplication.class); - String[] beanDefinitionNames = applicationContext.getBeanFactory().getBeanDefinitionNames(); - for (String beanDefinitionName : beanDefinitionNames) { - log.info("beanDefinitionName:{}", beanDefinitionName); - } } } 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 405d634..79e6f04 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 @@ -3,13 +3,13 @@ package com.muyu.cloud.pay.controller; import com.dtflys.forest.springboot.annotation.ForestScannerRegister; import com.muyu.cloud.domain.OrderPayCustomer; import com.muyu.cloud.domain.req.CustomerListReq; +import com.muyu.cloud.domain.req.OrderCustomerAddReq; import com.muyu.cloud.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.beans.factory.annotation.Autowired; import org.springframework.validation.annotation.Validated; @@ -66,4 +66,16 @@ public class OrderPayCustomerController { orderPayCustomerService.getCustomerAllList() ); } + + /** + * 添加客户 + * @param orderCustomerAddReq + * @return + */ + @PostMapping + @Operation(summary = "客户信息添加", description = "添加支付平台信息, 添加成功之后才可以使用支付类的产品") + public Result save(@Validated @RequestBody OrderCustomerAddReq orderCustomerAddReq){ + orderPayCustomerService.save(OrderPayCustomer.addBuild(orderCustomerAddReq)); + return Result.success(); + } } 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 bb3bac9..962eb95 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 @@ -9,6 +9,7 @@ import com.muyu.cloud.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.core.exception.ServiceException; import com.muyu.common.core.utils.StringUtils; import com.muyu.common.nacos.service.NacosServerService; import lombok.extern.log4j.Log4j2; @@ -84,4 +85,14 @@ public class OrderPayCustomerServiceImpl .filter(nacosServer -> !customerSet.contains(nacosServer)) .toList(); } + + @Override + public boolean save(OrderPayCustomer orderPayCustomer) { + String appCode = orderPayCustomer.getAppCode(); + List customerAllList = this.getCustomerAllList(); + if (customerAllList.contains(appCode)){ + throw new ServiceException("客户编码重复"); + } + return super.save(orderPayCustomer); + } }