feat():新增添加查询
parent
d73a755c2f
commit
ab32fc459c
|
@ -4,6 +4,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;
|
||||
|
@ -54,7 +55,16 @@ public class OrderPayCustomer extends BaseEntity {
|
|||
|
||||
|
||||
|
||||
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,76 @@
|
|||
package com.muyu.cloud.pay.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:zhangchengzhi
|
||||
* @Package:com.muyu.cloud.pay.domain.req
|
||||
* @Project:cloud-pay
|
||||
* @name:OrderCustomerAddReq
|
||||
* @Date:2024/8/6 21:02
|
||||
*/
|
||||
@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 = {"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;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -1,6 +1,8 @@
|
|||
package com.muyu.cloud.pay.controller;
|
||||
|
||||
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;
|
||||
|
@ -44,9 +46,7 @@ public class OrderPayCustomerController {
|
|||
public Result<List<CustomerResp>> selectList(@Validated @RequestBody CustomerListReq customerListReq) {
|
||||
|
||||
return Result.success(orderPayCustomerService.selectList(customerListReq));
|
||||
}
|
||||
|
||||
;
|
||||
};
|
||||
|
||||
/**
|
||||
* 获取所有客户的
|
||||
|
@ -65,4 +65,26 @@ public class OrderPayCustomerController {
|
|||
);//客户业务层
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加客户
|
||||
* @param orderCustomerAddReq 客户信息
|
||||
* @return 添加结果
|
||||
*/
|
||||
@PostMapping
|
||||
@Operation(summary = "客户信息添加",description = "添加支付平台客户信息,添加成功后才可以使用支付类的产品")
|
||||
public Result<String> save(@Validated @RequestBody OrderCustomerAddReq orderCustomerAddReq){
|
||||
|
||||
orderPayCustomerService.save(OrderPayCustomer.addBuild(orderCustomerAddReq));
|
||||
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ import com.muyu.cloud.pay.mapper.OrderPayCustomerMapper;
|
|||
import com.muyu.cloud.pay.service.OrderPayCustomerService;
|
||||
import com.muyu.cloud.pay.service.OrderPayInfoService;
|
||||
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.remote.service.NacosServerService;
|
||||
import jakarta.annotation.Resource;
|
||||
|
@ -19,6 +20,7 @@ import lombok.extern.log4j.Log4j2;
|
|||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.rmi.ServerException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
@ -89,4 +91,26 @@ public class OrderPayCustomerServiceImpl extends ServiceImpl<OrderPayCustomerMap
|
|||
.filter(nacosServer -> !customerSet.contains(nacosServer))
|
||||
.toList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean save(OrderPayCustomer orderPayCustomer) {
|
||||
|
||||
String appCode = orderPayCustomer.getAppCode();
|
||||
List<String> customerAllList = this.getCustomerAllList();
|
||||
List<String> naocsServiceAllList = nacosServerService.naocsServiceAllList();
|
||||
if (!naocsServiceAllList.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