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

@Injectable()
export class CreateTermConditionManager extends BaseCreateManager<TermConditionEntity> {
  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: TermConditionCreatedEvent,
        data: this.data,
      },
    ];
  }

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