import { Injectable } from '@nestjs/common';
import { BaseDetailManager } from 'src/core/modules/domain/usecase/managers/base-detail.manager';
import { UserEntity } from '../../entities/user.entity';
import { RelationParam } from 'src/core/modules/domain/entities/base-filter.entity';

@Injectable()
export class DetailUserManager extends BaseDetailManager<UserEntity> {
  async prepareData(): Promise<void> {
    return;
  }

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

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

  get relations(): RelationParam {
    return {
      // relation only join (for query purpose)
      joinRelations: [],

      // relation join and select (relasi yang ingin ditampilkan),
      selectRelations: ['user_privilege'],

      // relation yang hanya ingin dihitung (akan return number)
      countRelations: [],
    };
  }

  get selects(): string[] {
    return [
      `${this.tableName}.id`,
      `${this.tableName}.status`,
      `${this.tableName}.name`,
      `${this.tableName}.username`,
      `${this.tableName}.role`,
      `${this.tableName}.created_at`,
      `${this.tableName}.creator_name`,
      `${this.tableName}.updated_at`,
      `${this.tableName}.editor_name`,

      'user_privilege.id',
      'user_privilege.name',
    ];
  }

  get setFindProperties(): any {
    return {
      id: this.dataId,
    };
  }
}
