import { ApiProperty } from '@nestjs/swagger';
import { IsObject, IsString, ValidateIf } from 'class-validator';
import { QueryModelEntity } from '../entities/query-model.entity';
import { REPORT_GROUP } from '../constant';

export class GetReportDataDto {
  @ApiProperty({
    name: 'group_name',
    required: true,
    default: REPORT_GROUP.transaction_report,
  })
  @IsString()
  group_name: string;

  @ApiProperty({
    name: 'unique_name',
    required: true,
    default: `${REPORT_GROUP.transaction_report}__sample`,
  })
  @IsString()
  unique_name: string;

  @ApiProperty({
    name: 'query_model',
    type: Object,
    required: true,
    default: {
      startRow: 0,
      endRow: 100,
      rowGroupCols: [],
      valueCols: [],
      pivotCols: [],
      pivotMode: true,
      groupKeys: [],
      filterModel: {},
      sortModel: [],
    },
  })
  @IsObject()
  @ValidateIf((body) => body.query_model)
  query_model: QueryModelEntity;
}
