import { Provide, Post, Inject, Body, ALL } from '@midwayjs/decorator';
import { CoolController, BaseController } from '@cool-midway/core';
import { DispatchService } from '../../service/channels/dispatch';
import { WithdrawChannelEntity } from '../../entity/withdrawChannel';
import { WithdrawChannelService } from '../../service/withdrawChannel';

@Provide()
@CoolController({
  api: ['add', 'delete', 'update', 'list', 'info', 'page'],
  entity: WithdrawChannelEntity,
  service: WithdrawChannelService,
  pageQueryOp: {
    keyWordLikeFields: ['name', 'code', 'currency'],
  },
})
export class WithdrawChannelController extends BaseController {
  @Inject()
  withdrawChannelService: WithdrawChannelService;

  @Inject()
  dispatchService: DispatchService;

  @Post('/queryChannelBalance', { summary: '获取通道余额' })
  async queryChannelBalance(@Body(ALL) payload: any) {
    return this.ok(await this.dispatchService.queryBalance(payload.code));
  }
}
