feat: add filter data scheduling date

pull/178/head
Firman Ramdhani 2025-07-11 11:42:08 +07:00
parent 0e8256bee7
commit 5d94c7a07c
4 changed files with 43 additions and 4 deletions

View File

@ -74,10 +74,25 @@ export class IndexDataSchedulingLogManager extends BaseIndexManager<DataScheduli
if (this.filterParam.schedule_date_to) { if (this.filterParam.schedule_date_to) {
const dateTo = this.filterParam.schedule_date_to; const dateTo = this.filterParam.schedule_date_to;
queryBuilder.andWhere('schedule_date_from <= :dateTo', { queryBuilder.andWhere('schedule_date_to <= :dateTo', {
dateTo: dateTo, dateTo: dateTo,
}); });
} }
if (this.filterParam.log_created_from) {
const dateFrom = this.filterParam.log_created_from;
queryBuilder.andWhere('log_created_from >= :dateFrom', {
dateFrom: dateFrom,
});
}
if (this.filterParam.log_created_to) {
const dateTo = this.filterParam.log_created_to;
queryBuilder.andWhere('log_created_to <= :dateTo', {
dateTo: dateTo,
});
}
return queryBuilder; return queryBuilder;
} }

View File

@ -67,7 +67,7 @@ export class IndexDataSchedulingManager extends BaseIndexManager<DataSchedulingE
if (this.filterParam.schedule_date_to) { if (this.filterParam.schedule_date_to) {
const dateTo = this.filterParam.schedule_date_to; const dateTo = this.filterParam.schedule_date_to;
queryBuilder.andWhere('schedule_date_from <= :dateTo', { queryBuilder.andWhere('schedule_date_to <= :dateTo', {
dateTo: dateTo, dateTo: dateTo,
}); });
} }

View File

@ -1,5 +1,8 @@
import { Controller, Get, Param, Query } from '@nestjs/common'; import { Controller, Get, Param, Query } from '@nestjs/common';
import { FilterDataSchedulingDto } from './dto/filter-data-scheduling.dto'; import {
FilterDataSchedulingDto,
FilterDataSchedulingLogDto,
} from './dto/filter-data-scheduling.dto';
import { Pagination } from 'src/core/response'; import { Pagination } from 'src/core/response';
import { PaginationResponse } from 'src/core/response/domain/ok-response.interface'; import { PaginationResponse } from 'src/core/response/domain/ok-response.interface';
import { import {
@ -43,7 +46,7 @@ export class DataSchedulingLogReadController {
@Pagination() @Pagination()
@ExcludePrivilege() @ExcludePrivilege()
async index( async index(
@Query() params: FilterDataSchedulingDto, @Query() params: FilterDataSchedulingLogDto,
): Promise<PaginationResponse<DataSchedulingLogEntity>> { ): Promise<PaginationResponse<DataSchedulingLogEntity>> {
return await this.orchestrator.indexLog(params); return await this.orchestrator.indexLog(params);
} }

View File

@ -16,6 +16,27 @@ export class FilterDataSchedulingDto
schedule_date_to: Date; schedule_date_to: Date;
} }
export class FilterDataSchedulingLogDto
extends BaseFilterDto
implements FilterDataSchedulingEntity
{
@ApiProperty({ type: 'string', required: false })
@ValidateIf((body) => body.schedule_date_from)
schedule_date_from: Date;
@ApiProperty({ type: 'string', required: false })
@ValidateIf((body) => body.schedule_date_to)
schedule_date_to: Date;
@ApiProperty({ type: Number, required: false })
@ValidateIf((body) => body.log_created_from)
log_created_from: number;
@ApiProperty({ type: Number, required: false })
@ValidateIf((body) => body.log_created_to)
log_created_to: number;
}
export class FilterActiveDataSchedulingDto { export class FilterActiveDataSchedulingDto {
// @ApiProperty({ type: 'string', required: true }) // @ApiProperty({ type: 'string', required: true })
// @ValidateIf((body) => body.schedule_date_from) // @ValidateIf((body) => body.schedule_date_from)