|
@@ -8,8 +8,12 @@ import {
|
|
|
Post,
|
|
|
Provide,
|
|
|
Put,
|
|
|
+ Query,
|
|
|
+ Param,
|
|
|
} from '@midwayjs/decorator';
|
|
|
import { BusinessEntity } from '../../payment/entity/business';
|
|
|
+import { PayeeAddressService } from '../../payment/service/payee_address';
|
|
|
+import { BeneficiaryAddressService } from '../service/beneficiaryAddress';
|
|
|
|
|
|
/**
|
|
|
* 受益人地址
|
|
@@ -17,57 +21,56 @@ import { BusinessEntity } from '../../payment/entity/business';
|
|
|
@Provide()
|
|
|
@CoolController('/api/v1/Fiat')
|
|
|
export class BeneficiaryAddressController extends BaseController {
|
|
|
+ @Inject()
|
|
|
+ payeeAddressService: PayeeAddressService;
|
|
|
+
|
|
|
+ @Inject()
|
|
|
+ beneficiaryAddressService: BeneficiaryAddressService;
|
|
|
+
|
|
|
/**
|
|
|
* 创建受益人地址
|
|
|
* /api/v3/Fiat/BeneficiaryAddress
|
|
|
*/
|
|
|
@Post('/BeneficiaryAddress', { summary: '创建受益人地址' })
|
|
|
- async createBeneficiaryAddress(@Body(ALL) business: BusinessEntity) {
|
|
|
- // if (!this.allowKeys.includes(key)) {
|
|
|
- // return this.fail('非法操作');
|
|
|
- // }
|
|
|
- // 关键参数校验
|
|
|
- // 数据落库
|
|
|
- // 回调
|
|
|
- console.log(business);
|
|
|
- return this.ok('hello, cool-admin!!!');
|
|
|
+ async createBeneficiaryAddress(@Body(ALL) params: BusinessEntity) {
|
|
|
+ return this.ok(await this.payeeAddressService.add(params));
|
|
|
}
|
|
|
/**
|
|
|
* 获取受益人地址必填字段
|
|
|
* /api/v3/Fiat/BeneficiaryAddressRequiredFields
|
|
|
*/
|
|
|
- @Get('/BeneficiaryAddressRequiredFields', {
|
|
|
- summary: '获取受益人地址必填字段',
|
|
|
- })
|
|
|
- async getBeneficiaryAddressRequiredFields(
|
|
|
- @Body(ALL) business: BusinessEntity
|
|
|
- ) {
|
|
|
- // if (!this.allowKeys.includes(key)) {
|
|
|
- // return this.fail('非法操作');
|
|
|
- // }
|
|
|
- // 关键参数校验
|
|
|
- // 数据落库
|
|
|
- // 回调
|
|
|
- console.log(business);
|
|
|
- return this.ok('hello, cool-admin!!!');
|
|
|
- }
|
|
|
+ // @Get('/BeneficiaryAddressRequiredFields', {
|
|
|
+ // summary: '获取受益人地址必填字段',
|
|
|
+ // })
|
|
|
+ // async getBeneficiaryAddressRequiredFields(
|
|
|
+ // @Body(ALL) business: BusinessEntity
|
|
|
+ // ) {
|
|
|
+ // // if (!this.allowKeys.includes(key)) {
|
|
|
+ // // return this.fail('非法操作');
|
|
|
+ // // }
|
|
|
+ // // 关键参数校验
|
|
|
+ // // 数据落库
|
|
|
+ // // 回调
|
|
|
+ // console.log(business);
|
|
|
+ // return this.ok('hello, cool-admin!!!');
|
|
|
+ // }
|
|
|
/**
|
|
|
* 验证受益人地址必填字段
|
|
|
* /api/v3/Fiat/BeneficiaryAddress/Validate
|
|
|
*/
|
|
|
- @Post('/BeneficiaryAddress/Validate', {
|
|
|
- summary: '验证受益人地址必填字段',
|
|
|
- })
|
|
|
- async BeneficiaryAddressValidate(@Body(ALL) business: BusinessEntity) {
|
|
|
- // if (!this.allowKeys.includes(key)) {
|
|
|
- // return this.fail('非法操作');
|
|
|
- // }
|
|
|
- // 关键参数校验
|
|
|
- // 数据落库
|
|
|
- // 回调
|
|
|
- console.log(business);
|
|
|
- return this.ok('hello, cool-admin!!!');
|
|
|
- }
|
|
|
+ // @Post('/BeneficiaryAddress/Validate', {
|
|
|
+ // summary: '验证受益人地址必填字段',
|
|
|
+ // })
|
|
|
+ // async BeneficiaryAddressValidate(@Body(ALL) business: BusinessEntity) {
|
|
|
+ // // if (!this.allowKeys.includes(key)) {
|
|
|
+ // // return this.fail('非法操作');
|
|
|
+ // // }
|
|
|
+ // // 关键参数校验
|
|
|
+ // // 数据落库
|
|
|
+ // // 回调
|
|
|
+ // console.log(business);
|
|
|
+ // return this.ok('hello, cool-admin!!!');
|
|
|
+ // }
|
|
|
/**
|
|
|
* 修改受益人地址
|
|
|
* /api/v3/Fiat/BeneficiaryAddress
|
|
@@ -75,15 +78,8 @@ export class BeneficiaryAddressController extends BaseController {
|
|
|
@Put('/BeneficiaryAddress', {
|
|
|
summary: '修改受益人地址',
|
|
|
})
|
|
|
- async updateBeneficiaryAddress(@Body(ALL) business: BusinessEntity) {
|
|
|
- // if (!this.allowKeys.includes(key)) {
|
|
|
- // return this.fail('非法操作');
|
|
|
- // }
|
|
|
- // 关键参数校验
|
|
|
- // 数据落库
|
|
|
- // 回调
|
|
|
- console.log(business);
|
|
|
- return this.ok('hello, cool-admin!!!');
|
|
|
+ async updateBeneficiaryAddress(@Body(ALL) params: BusinessEntity) {
|
|
|
+ return this.ok(await this.payeeAddressService.update(params));
|
|
|
}
|
|
|
/**
|
|
|
* 获取受益人地址
|
|
@@ -92,15 +88,9 @@ export class BeneficiaryAddressController extends BaseController {
|
|
|
@Get('/BeneficiaryAddress/:id', {
|
|
|
summary: '获取受益人地址',
|
|
|
})
|
|
|
- async getBeneficiaryAddressForId(@Body(ALL) business: BusinessEntity) {
|
|
|
- // if (!this.allowKeys.includes(key)) {
|
|
|
- // return this.fail('非法操作');
|
|
|
- // }
|
|
|
- // 关键参数校验
|
|
|
- // 数据落库
|
|
|
- // 回调
|
|
|
- console.log(business);
|
|
|
- return this.ok('hello, cool-admin!!!');
|
|
|
+ async getBeneficiaryAddressForId(@Param('id') id: string) {
|
|
|
+ console.log(98989, id);
|
|
|
+ return this.ok(await this.beneficiaryAddressService.info(id));
|
|
|
}
|
|
|
/**
|
|
|
* 获取受益人地址列表
|
|
@@ -109,32 +99,46 @@ export class BeneficiaryAddressController extends BaseController {
|
|
|
@Get('/BeneficiaryAddress', {
|
|
|
summary: '获取受益人地址列表',
|
|
|
})
|
|
|
- async getBeneficiaryAddress(@Body(ALL) business: BusinessEntity) {
|
|
|
+ async getBeneficiaryAddress(
|
|
|
+ @Query('customer_id') customerId: string,
|
|
|
+ @Query('currency') currency: string,
|
|
|
+ @Query('payment_type') paymentType: string,
|
|
|
+ @Query('page_index') pageIndex: number,
|
|
|
+ @Query('page_size') pageSize: number
|
|
|
+ ) {
|
|
|
// if (!this.allowKeys.includes(key)) {
|
|
|
// return this.fail('非法操作');
|
|
|
// }
|
|
|
// 关键参数校验
|
|
|
// 数据落库
|
|
|
// 回调
|
|
|
- console.log(business);
|
|
|
- return this.ok('hello, cool-admin!!!');
|
|
|
+ // http://127.0.0.1:8008/api/v1/Fiat/BeneficiaryAddress?page_size=12&page_index=1&payment_type=¤cy=&customer_id=18
|
|
|
+ const result = await this.beneficiaryAddressService.getBeneficiaryAddress(
|
|
|
+ customerId,
|
|
|
+ currency,
|
|
|
+ paymentType,
|
|
|
+ pageIndex,
|
|
|
+ pageSize
|
|
|
+ );
|
|
|
+ return this.ok({
|
|
|
+ success: true,
|
|
|
+ data: result.data,
|
|
|
+ total: result.total,
|
|
|
+ });
|
|
|
}
|
|
|
/**
|
|
|
* 删除受益人地址
|
|
|
* /api/v3/Fiat/BeneficiaryAddress/{id}
|
|
|
*/
|
|
|
// delete 请求存疑
|
|
|
- @Del('/BeneficiaryAddress/:id', {
|
|
|
+ @Del('/DelBeneficiaryAddress/:id', {
|
|
|
summary: '删除受益人地址',
|
|
|
})
|
|
|
async deleteBeneficiaryAddressForId(@Body(ALL) business: BusinessEntity) {
|
|
|
- // if (!this.allowKeys.includes(key)) {
|
|
|
- // return this.fail('非法操作');
|
|
|
- // }
|
|
|
- // 关键参数校验
|
|
|
- // 数据落库
|
|
|
- // 回调
|
|
|
- console.log(business);
|
|
|
- return this.ok('hello, cool-admin!!!');
|
|
|
+ return this.ok(
|
|
|
+ await this.payeeAddressService.delete({
|
|
|
+ id: business.id,
|
|
|
+ })
|
|
|
+ );
|
|
|
}
|
|
|
}
|