import { Injectable } from '@nestjs/common';
import {
  EventTopics,
  columnUniques,
  validateRelations,
} from 'src/core/strings/constants/interface.constants';
import { PaymentMethodEntity } from '../../entities/payment-method.entity';
import { PaymentMethodModel } from '../../../data/models/payment-method.model';
import { BaseCreateManager } from 'src/core/modules/domain/usecase/managers/base-create.manager';
import { PaymentMethodCreatedEvent } from '../../entities/event/payment-method-created.event';

@Injectable()
export class CreatePaymentMethodManager extends BaseCreateManager<PaymentMethodEntity> {
  async beforeProcess(): Promise<void> {
    return;
  }

  async afterProcess(): Promise<void> {
    return;
  }

  get validateRelations(): validateRelations[] {
    return [];
  }

  get uniqueColumns(): columnUniques[] {
    // return [{ column: 'account_number' }, { column: 'account_name' }];
    return [
      {
        column: 'account_number',
        query: { account_name: this.data.account_name, type: this.data.type },
      },
    ];
  }

  get eventTopics(): EventTopics[] {
    return [
      {
        topic: PaymentMethodCreatedEvent,
        data: this.data,
      },
    ];
  }

  get entityTarget(): any {
    return PaymentMethodModel;
  }
}
