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

@Injectable()
export class CreateItemCategoryManager extends BaseCreateManager<ItemCategoryEntity> {
  async beforeProcess(): Promise<void> {
    Object.assign(this.data, {
      item_type: this.data.item_type.toLowerCase(),
    });
    return;
  }

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

  async generateConfig(): Promise<void> {
    // TODO: Implement logic here
  }

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

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

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

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