customer.ts 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. import {CreateCustomerDTO} from "../dto/customer";
  2. import { CoolController, BaseController } from '@cool-midway/core';
  3. import {
  4. ALL,
  5. Body,
  6. Get,
  7. Inject, Param,
  8. Post,
  9. Provide,
  10. Put,
  11. } from '@midwayjs/decorator';
  12. import { BusinessEntity } from '../../payment/entity/business';
  13. import {Validate} from "@midwayjs/validate";
  14. import {BusinessService} from "../../payment/service/business";
  15. import {PaymentService} from "../../payment/service/payment";
  16. /**
  17. * 客户管理
  18. */
  19. @Provide()
  20. @CoolController('/api/v1/Fiat')
  21. export class CustomerController extends BaseController {
  22. @Inject()
  23. businessService: BusinessService;
  24. /**
  25. * 创建客户
  26. */
  27. @Post('/CreateCustomer', { summary: '创建客户' })
  28. @Validate({
  29. errorStatus: 422,
  30. })
  31. async createCustomer(@Body() params: CreateCustomerDTO) {
  32. return this.ok(params);
  33. // return this.ok(await this.businessService.add(params));
  34. }
  35. /**
  36. * 获取创建客户必填字段
  37. */
  38. @Get('/CustomerRequiredFields', { summary: '获取创建客户必填字段' })
  39. async getCustomerRequiredFields(@Body(ALL) business: BusinessEntity) {
  40. // if (!this.allowKeys.includes(key)) {
  41. // return this.fail('非法操作');
  42. // }
  43. // 关键参数校验
  44. // 数据落库
  45. // 回调
  46. console.log(business);
  47. return this.ok('hello, cool-admin!!!');
  48. }
  49. /**
  50. * 验证客户必填字段
  51. * /api/v3/Fiat/Customer/Validate
  52. */
  53. @Post('/Customer/Validate', { summary: '验证客户必填字段' })
  54. async param(@Body(ALL) business: BusinessEntity) {
  55. // if (!this.allowKeys.includes(key)) {
  56. // return this.fail('非法操作');
  57. // }
  58. // 关键参数校验
  59. // 数据落库
  60. // 回调
  61. console.log(business);
  62. return this.ok('hello, cool-admin!!!');
  63. }
  64. /**
  65. * 修改客户
  66. * /api/v3/Fiat/Customer
  67. */
  68. @Put('/updateCustomer', { summary: '修改客户' })
  69. async updateCustomer(@Body(ALL) business: BusinessEntity) {
  70. // if (!this.allowKeys.includes(key)) {
  71. // return this.fail('非法操作');
  72. // }
  73. // 关键参数校验
  74. // 数据落库
  75. // 回调
  76. console.log(business);
  77. return this.ok('hello, cool-admin!!!');
  78. }
  79. /**
  80. * TODO 创建客户回调通知
  81. *
  82. */
  83. @Post('/callback', { summary: '创建客户回调通知' })
  84. async createCustomerCallback(@Body(ALL) business: BusinessEntity) {
  85. // if (!this.allowKeys.includes(key)) {
  86. // return this.fail('非法操作');
  87. // }
  88. // 关键参数校验
  89. // 数据落库
  90. // 回调
  91. console.log(business);
  92. return this.ok('hello, cool-admin!!!');
  93. }
  94. }