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

@Injectable()
export class CreateFaqManager extends BaseCreateManager<FaqEntity> {
  async beforeProcess(): Promise<void> {
    const sortColumn = await this.dataService.getSortColumn();

    Object.assign(this.data, {
      sort_order: sortColumn,
    });
    return;
  }

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

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

  get uniqueColumns(): columnUniques[] {
    return [];
  }

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

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