import { BaseCreateManager } from 'src/core/modules/domain/usecase/managers/base-create.manager';
import { UserPrivilegeEntity } from '../../../entities/user-privilege.entity';
import { Injectable } from '@nestjs/common';
import { UserPrivilegeModel } from '../../../../data/models/user-privilege.model';
import {
  EventTopics,
  columnUniques,
} from 'src/core/strings/constants/interface.constants';
import { UserPrivilegeCreatedEvent } from '../../../entities/event/user-privilege-created.event';
import { UserPrivilegeConfigurationHelper } from '../../user-privilege-configuration/helpers/generate-user-privilege-configuration.helper';

@Injectable()
export class CreateUserPrivilegeManager extends BaseCreateManager<UserPrivilegeEntity> {
  async beforeProcess(): Promise<void> {
    const configs = UserPrivilegeConfigurationHelper.createConfigurations();
    Object.assign(this.data, {
      user_privilege_configurations: configs,
    });

    return;
  }

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

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

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

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

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