import {
  HttpStatus,
  Injectable,
  UnprocessableEntityException,
} from '@nestjs/common';
import {
  EventTopics,
  columnUniques,
  validateRelations,
} from 'src/core/strings/constants/interface.constants';
import { GateEntity } from '../../entities/gate.entity';
import { GateModel } from '../../../data/models/gate.model';
import { BaseCreateManager } from 'src/core/modules/domain/usecase/managers/base-create.manager';
import { GateCreatedEvent } from '../../entities/event/gate-created.event';
import { validateItemGate } from './helpers/validate-item-gate.helper';

@Injectable()
export class CreateGateManager extends BaseCreateManager<GateEntity> {
  async beforeProcess(): Promise<void> {
    await validateItemGate(this.dataService, this.data);
    return;
  }

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

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

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

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

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