import { Injectable } from '@nestjs/common';
import { BaseIndexManager } from 'src/core/modules/domain/usecase/managers/base-index.manager';
import { TaxEntity } from '../../entities/tax.entity';
import { SelectQueryBuilder } from 'typeorm';
import {
  Param,
  RelationParam,
} from 'src/core/modules/domain/entities/base-filter.entity';

@Injectable()
export class IndexTaxManager extends BaseIndexManager<TaxEntity> {
  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: [],

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

  get selects(): string[] {
    return [
      `${this.tableName}.id`,
      `${this.tableName}.status`,
      `${this.tableName}.name`,
      `${this.tableName}.value`,
      `${this.tableName}.created_at`,
      `${this.tableName}.updated_at`,
      `${this.tableName}.creator_id`,
      `${this.tableName}.editor_id`,
    ];
  }

  get specificFilter(): Param[] {
    return [
      {
        cols: `${this.tableName}.name`,
        data: this.filterParam.names,
      },
      {
        cols: `${this.tableName}.value`,
        data: this.filterParam.values,
      },
    ];
  }

  setQueryFilter(
    queryBuilder: SelectQueryBuilder<TaxEntity>,
  ): SelectQueryBuilder<TaxEntity> {
    return queryBuilder;
  }
}
