import { BaseFilterDto } from 'src/core/modules/infrastructure/dto/base-filter.dto';
import { FilterUserEntity } from '../../domain/entities/filter-user.entity';
import { ApiProperty } from '@nestjs/swagger';
import { Transform } from 'class-transformer';

export class FilterUserDto extends BaseFilterDto implements FilterUserEntity {
  // for searching
  @ApiProperty({ type: ['string'], required: false })
  @Transform((body) => {
    return Array.isArray(body.value) ? body.value : [body.value];
  })
  usernames: string[];

  @ApiProperty({ type: ['string'], required: false })
  @Transform((body) => {
    return Array.isArray(body.value) ? body.value : [body.value];
  })
  user_privileges: string[];

  // for filtering
  @ApiProperty({ type: ['string'], required: false })
  @Transform((body) => {
    return Array.isArray(body.value) ? body.value : [body.value];
  })
  user_privilege_ids: string[];
}
