106 lines
4.4 KiB
Java
106 lines
4.4 KiB
Java
package com.muyu.pay.controller;
|
||
|
||
import com.dtflys.forest.springboot.annotation.ForestScannerRegister;
|
||
import com.muyu.common.core.domain.Result;
|
||
import com.muyu.domain.OrderPayCustomer;
|
||
import com.muyu.domain.req.CustomerListReq;
|
||
import com.muyu.domain.req.OrderCustomerAddReq;
|
||
import com.muyu.domain.req.OrderCustomerUpdReq;
|
||
import com.muyu.domain.resp.CustomerResp;
|
||
import com.muyu.pay.service.OrderPayCustomerService;
|
||
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;
|
||
import org.springframework.web.bind.annotation.*;
|
||
|
||
import java.util.List;
|
||
|
||
@Log4j2
|
||
@RestController
|
||
@RequestMapping("/customer")
|
||
@Tag(name = "客户控制层", description = "进行客户管理、查看等相关操作")
|
||
public class OrderPayCustomerController {
|
||
|
||
public OrderPayCustomerController () {
|
||
log.info("forest扫描路径:{}", ForestScannerRegister.getBasePackages());
|
||
}
|
||
|
||
|
||
@Autowired
|
||
private OrderPayCustomerService orderPayCustomerService;
|
||
|
||
|
||
@RequestMapping(path = "/list", method = RequestMethod.POST)
|
||
@Operation(summary = "查看客户", description = "根据客户的名称、编码、是否开启等可以进行客户的筛选")
|
||
public Result<List<CustomerResp>> selectList(
|
||
@Validated @RequestBody CustomerListReq customerListReq) {
|
||
return Result.success(
|
||
orderPayCustomerService.selectList(customerListReq)
|
||
);
|
||
}
|
||
|
||
|
||
@GetMapping("/all")
|
||
@Operation(summary = "获取未接入的客户", description = "调用nacosAPI获取所有的微服务名称,作为支付中台的客户")
|
||
@Schema(description = "获取未接入的客户", defaultValue = "[\"客户1\",\"客户2\"]", type = "List")
|
||
public Result<List<String>> getCustomerAllList(){
|
||
return Result.success(
|
||
orderPayCustomerService.getCustomerAllList()
|
||
);
|
||
}
|
||
|
||
|
||
@PostMapping
|
||
@Operation(summary = "客户信息添加",description = "添加支付平台客户信息,添加成功之后才可以使用支付类的产品")
|
||
public Result<String> save(@Validated @RequestBody OrderCustomerAddReq orderCustomerAddReq) {
|
||
orderPayCustomerService.save(OrderPayCustomer.addBuild(orderCustomerAddReq));
|
||
return Result.success(null, "操作成功");
|
||
}
|
||
|
||
|
||
@PutMapping("/{orderCustomerId}")
|
||
@Operation(summary = "客户信息修改", description = "通过ID修改客户信息")
|
||
public Result<String> update(
|
||
@Schema(title = "客户ID", type = "Long", defaultValue = "1", description = "修改客户信息需要依据的唯一条件")
|
||
@PathVariable("orderCustomerId") Long orderCustomerId,
|
||
@RequestBody @Validated OrderCustomerUpdReq orderCustomerUpdReq){
|
||
orderPayCustomerService.updateById(OrderPayCustomer.updBuild(orderCustomerUpdReq, () -> orderCustomerId));
|
||
return Result.success(null, "操作成功");
|
||
}
|
||
|
||
|
||
@DeleteMapping("/{orderCustomerId}")
|
||
@Operation(summary = "客户信息删除", description = "通过ID删除客户信息")
|
||
public Result<String> delete(@PathVariable("orderCustomerId") Long orderCustomerId){
|
||
orderPayCustomerService.removeById(orderCustomerId);
|
||
return Result.success(null, "操作成功");
|
||
}
|
||
|
||
|
||
@GetMapping("/{orderCustomerId}")
|
||
@Operation(summary = "通过ID获取客户信息", description = "通过ID获取客户信息")
|
||
public Result<OrderPayCustomer> findById(@PathVariable("orderCustomerId") Long orderCustomerId){
|
||
return Result.success(orderPayCustomerService.getById(orderCustomerId), "操作成功");
|
||
}
|
||
|
||
|
||
@GetMapping("/disable/{orderCustomerId}")
|
||
@Operation(summary = "通过ID禁用客户", description = "通过ID禁用客户")
|
||
public Result<String> disable(@PathVariable("orderCustomerId") Long orderCustomerId){
|
||
this.orderPayCustomerService.disable(orderCustomerId);
|
||
return Result.success(null, "操作成功");
|
||
}
|
||
|
||
|
||
@GetMapping("/enable/{orderCustomerId}")
|
||
@Operation(summary = "通过ID启用客户", description = "通过ID启用客户")
|
||
public Result<String> enable(@PathVariable("orderCustomerId") Long orderCustomerId){
|
||
this.orderPayCustomerService.enable(orderCustomerId);
|
||
return Result.success(null, "操作成功");
|
||
}
|
||
}
|