feat():增加了客户添加接口
parent
7575120f80
commit
800f9930ad
|
@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.annotation.IdType;
|
|||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.muyu.common.core.web.domain.BaseEntity;
|
||||
import com.muyu.pay.common.domain.req.CustomerAddReq;
|
||||
import lombok.*;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
|
@ -43,6 +44,17 @@ public class OrderPayCustomer extends BaseEntity {
|
|||
private String status;
|
||||
|
||||
|
||||
public static OrderPayCustomer addBuild(CustomerAddReq customerAddReq){
|
||||
return OrderPayCustomer.builder()
|
||||
.appName(customerAddReq.getAppName())
|
||||
.appCode(customerAddReq.getAppCode())
|
||||
.appDesc(customerAddReq.getAppDesc())
|
||||
.status(customerAddReq.getStatus())
|
||||
.remark(customerAddReq.getRemark())
|
||||
.build();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,68 @@
|
|||
package com.muyu.pay.common.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;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Tag(name = "支付服务客户请求对象",description = "根据入参进行服务的添加")
|
||||
public class CustomerAddReq {
|
||||
/**
|
||||
* 服务/客户名称
|
||||
*/
|
||||
@NotEmpty(message = "服务/客户名称不可为空")
|
||||
@Schema(
|
||||
title = "服务客户名称",
|
||||
description = "客户名称一般为微服务详细中文名称 方便使用者区分",
|
||||
type = "String",
|
||||
defaultValue = "会员服务",
|
||||
requiredProperties ={"appName"}
|
||||
)
|
||||
private String appName;
|
||||
|
||||
/**
|
||||
* 服务/客户编码
|
||||
*/
|
||||
@NotBlank(message = "服务/客户编码不可为空")
|
||||
@Schema(
|
||||
title = "客户编码",
|
||||
description = "客户编码为微服务的namespace名称",
|
||||
type = "String",
|
||||
defaultValue = "muyu-vip",
|
||||
requiredProperties = {"appCode"}
|
||||
)
|
||||
private String appCode;
|
||||
|
||||
/**
|
||||
* 客户描述
|
||||
*/
|
||||
@Schema(title = "客户描述",type = "String")
|
||||
private String appDesc;
|
||||
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
@Schema(
|
||||
title = "开通状态",description = "状态为Y和N 如果为Y客户可以使用支付接口为N不可以使用客户接口",
|
||||
type = "String",defaultValue = "Y"
|
||||
)
|
||||
@NotEmpty(message = "客户使用状态不能为空")
|
||||
@IsSystemYesNo
|
||||
private String status;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
@Schema(title = "客户备注",type = "String")
|
||||
private String remark;
|
||||
|
||||
}
|
|
@ -3,6 +3,7 @@ package com.muyu.pay.server.controller;
|
|||
import com.dtflys.forest.springboot.annotation.ForestScannerRegister;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.pay.common.domain.OrderPayCustomer;
|
||||
import com.muyu.pay.common.domain.req.CustomerAddReq;
|
||||
import com.muyu.pay.common.domain.req.CustomerListReq;
|
||||
import com.muyu.pay.common.domain.resp.CustomerResp;
|
||||
import com.muyu.pay.server.service.OrderPayCustomerService;
|
||||
|
@ -57,4 +58,12 @@ public class OrderPayCustomerController {
|
|||
}
|
||||
|
||||
|
||||
@PostMapping
|
||||
@Operation(summary = "添加客户信息",description = "添加支付平台客户信息,添加成功后可以使用支付信息")
|
||||
public Result<String> save(@Validated @RequestBody CustomerAddReq customerAddReq){
|
||||
orderPayCustomerService.save(OrderPayCustomer.addBuild(customerAddReq));
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.muyu.pay.server.service.impl;
|
|||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.muyu.common.core.enums.SysPayType;
|
||||
import com.muyu.common.core.exception.ServiceException;
|
||||
import com.muyu.common.core.utils.StringUtils;
|
||||
import com.muyu.common.nacos.service.NacosServerService;
|
||||
import com.muyu.pay.common.domain.OrderPayCustomer;
|
||||
|
@ -76,7 +77,24 @@ public class OrderPayCustomerServiceImpl
|
|||
List<OrderPayCustomer> list = this.list(queryWrapper);
|
||||
Set<String> customerSet = list.stream().map(OrderPayCustomer::getAppCode).collect(Collectors.toSet());
|
||||
return nacosServerAllList.stream()
|
||||
.filter(nacosServer->!customerSet.contains(nacosServer))
|
||||
.filter(nacosServer -> !customerSet.contains(nacosServer))
|
||||
.toList();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean save(OrderPayCustomer orderPayCustomer) {
|
||||
|
||||
String appCode = orderPayCustomer.getAppCode();
|
||||
List<String> nacosServerAllList = nacosServerService.nacosServerAllList();
|
||||
if (nacosServerAllList.contains(appCode)){
|
||||
throw new ServiceException("客户编码违法");
|
||||
}
|
||||
LambdaQueryWrapper<OrderPayCustomer> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(OrderPayCustomer::getAppCode,appCode);
|
||||
if (this.count(queryWrapper)>0) {
|
||||
throw new ServiceException("客户编码重复");
|
||||
}
|
||||
return super.save(orderPayCustomer);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue