feat():增加客户新增接口
parent
0eb51d3bdd
commit
62889fb041
|
@ -3,6 +3,7 @@ package com.muyu.cloud.pay.domain;
|
|||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.muyu.cloud.pay.domain.req.OrderCustomerAddReq;
|
||||
import com.muyu.common.core.web.domain.BaseEntity;
|
||||
import lombok.*;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
@ -27,14 +28,13 @@ public class OrderPayCustomer extends BaseEntity {
|
|||
*/
|
||||
@TableId(value = "id",type= IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 服务/客户名称
|
||||
*/
|
||||
private String appName;
|
||||
|
||||
/**
|
||||
*服务/客户编码
|
||||
*服务/客户编码
|
||||
*/
|
||||
private String appCode;
|
||||
|
||||
|
@ -42,30 +42,19 @@ public class OrderPayCustomer extends BaseEntity {
|
|||
*客户描述
|
||||
*/
|
||||
private String appDesc;
|
||||
|
||||
/**
|
||||
*是否开启
|
||||
*状态
|
||||
*/
|
||||
private String status;
|
||||
|
||||
// /**
|
||||
// *
|
||||
// */
|
||||
// private String createdBy;
|
||||
//
|
||||
// /**
|
||||
// *
|
||||
// */
|
||||
// private String createdTime;
|
||||
//
|
||||
// /**
|
||||
// *
|
||||
// */
|
||||
// private String updateBy;
|
||||
//
|
||||
// /**
|
||||
// *
|
||||
// */
|
||||
// private String updatedTime;
|
||||
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();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,63 @@
|
|||
package com.muyu.cloud.pay.domain.req;
|
||||
|
||||
import com.muyu.cloud.pay.domain.OrderPayCustomer;
|
||||
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:yang
|
||||
* @Package:com.muyu.cloud.pay.domain.req
|
||||
* @Project:cloud-pay
|
||||
* @name:OrderCustomerAddReq
|
||||
* @Date:2024/8/10 19:18
|
||||
*/
|
||||
@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 = "muyu-vip",defaultValue = "会员服务",
|
||||
description = "客户编码,从[/customer/all]接口当中进行获取",requiredProperties = {"appCode"})
|
||||
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;
|
||||
}
|
|
@ -16,16 +16,16 @@ import org.springframework.context.ConfigurableApplicationContext;
|
|||
* @Date:2024/7/31 21:25
|
||||
*/
|
||||
@Log4j2
|
||||
@ForestScan(basePackages = "com.muyu.common.nacos.remote")
|
||||
@EnableCustomConfig
|
||||
@EnableMyFeignClients
|
||||
@SpringBootApplication
|
||||
public class MuYuPayApplication {
|
||||
public static void main(String[] args) {
|
||||
ConfigurableApplicationContext applicationContext = SpringApplication.run(MuYuPayApplication.class, args);
|
||||
String[] beanDefinitionNames = applicationContext.getBeanFactory().getBeanDefinitionNames();
|
||||
for (String beanDefinitionName : beanDefinitionNames) {
|
||||
log.info("beanDefinitionName:{}",beanDefinitionName);
|
||||
}
|
||||
SpringApplication.run(MuYuPayApplication.class, args);
|
||||
// ConfigurableApplicationContext applicationContext = SpringApplication.run(MuYuPayApplication.class, args);
|
||||
// String[] beanDefinitionNames = applicationContext.getBeanFactory().getBeanDefinitionNames();
|
||||
// for (String beanDefinitionName : beanDefinitionNames) {
|
||||
// log.info("beanDefinitionName:{}",beanDefinitionName);
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,59 +0,0 @@
|
|||
package com.muyu.cloud.pay;
|
||||
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.boot.ConfigurableBootstrapContext;
|
||||
import org.springframework.boot.SpringApplicationRunListener;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.core.env.ConfigurableEnvironment;
|
||||
|
||||
import java.time.Duration;
|
||||
|
||||
/**
|
||||
* @Author:yang
|
||||
* @Package:com.muyu.cloud.pay
|
||||
* @Project:cloud-pay
|
||||
* @name:MySpringApplicationRunllstener
|
||||
* @Date:2024/8/9 23:22
|
||||
*/
|
||||
@Log4j2
|
||||
public class MySpringApplicationRunlistener implements SpringApplicationRunListener {
|
||||
|
||||
public MySpringApplicationRunlistener() {
|
||||
log.info("MySpringApplicationRunlistener");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void starting(ConfigurableBootstrapContext bootstrapContext) {
|
||||
log.info("执行:{}","starting");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void environmentPrepared(ConfigurableBootstrapContext bootstrapContext, ConfigurableEnvironment environment) {
|
||||
log.info("执行:{}","environmentPrepared");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void contextPrepared(ConfigurableApplicationContext context) {
|
||||
log.info("执行:{}","contextPrepared");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void contextLoaded(ConfigurableApplicationContext context) {
|
||||
log.info("执行:{}","contextLoaded");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void started(ConfigurableApplicationContext context, Duration timeTaken) {
|
||||
log.info("执行:{}","started");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void ready(ConfigurableApplicationContext context, Duration timeTaken) {
|
||||
log.info("执行:{}","ready");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void failed(ConfigurableApplicationContext context, Throwable exception) {
|
||||
log.info("执行:{}","failed");
|
||||
}
|
||||
}
|
|
@ -3,6 +3,7 @@ package com.muyu.cloud.pay.controller;
|
|||
import com.dtflys.forest.springboot.annotation.ForestScannerRegister;
|
||||
import com.muyu.cloud.pay.domain.OrderPayCustomer;
|
||||
import com.muyu.cloud.pay.domain.req.CustomerListReq;
|
||||
import com.muyu.cloud.pay.domain.req.OrderCustomerAddReq;
|
||||
import com.muyu.cloud.pay.domain.resp.CustomerResp;
|
||||
import com.muyu.cloud.pay.service.OrderPayCustomerService;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
|
@ -69,4 +70,10 @@ public class OrderPayCustomerController {
|
|||
orderPayCustomerService.getCustomerAllList()
|
||||
);
|
||||
}
|
||||
@PostMapping
|
||||
@Operation(summary = "客户信息添加",description = "添加支付平台客户信息,添加成功之后才可以使用支付类的产品")
|
||||
public Result<String> save(@Validated @RequestBody OrderCustomerAddReq orderCustomerAddReq){
|
||||
orderPayCustomerService.save(OrderPayCustomer.addBuild(orderCustomerAddReq));
|
||||
return Result.success();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ 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.nacos.service.NacosServiceService;
|
||||
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
|
@ -86,8 +87,21 @@ public class OrderPayCustomerServiceImpl
|
|||
LambdaQueryWrapper<OrderPayCustomer> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.select(OrderPayCustomer::getAppCode);
|
||||
List<OrderPayCustomer> orderPayCustomerList = this.list(queryWrapper);
|
||||
Set<String> customerSet = orderPayCustomerList.stream().map(OrderPayCustomer::getAppCode).collect(Collectors.toSet());
|
||||
Set<String> customerSet
|
||||
= orderPayCustomerList.stream().map(OrderPayCustomer::getAppCode).collect(Collectors.toSet());
|
||||
|
||||
return nacosServerAllList.stream().filter(nacosService -> !customerSet.contains(nacosService)).toList();
|
||||
return nacosServerAllList.stream()
|
||||
.filter(nacosService -> !customerSet.contains(nacosService))
|
||||
.toList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean save(OrderPayCustomer orderPayCustomer) {
|
||||
String appCode = orderPayCustomer.getAppCode();
|
||||
List<String> customerAllList = this.getCustomerAllList();
|
||||
if (!customerAllList.contains(appCode)){
|
||||
throw new ServiceException("客户编码重复");
|
||||
}
|
||||
return super.save(orderPayCustomer);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
com.muyu.cloud.pay.MySpringApplicationRunlistener
|
Loading…
Reference in New Issue