From d95f8fd6e5b5448cf6095fdc7b65efbddb479847 Mon Sep 17 00:00:00 2001 From: shancheas Date: Mon, 9 Jun 2025 10:11:16 +0700 Subject: [PATCH] feat: add time_group_ids filter to item management and DTO --- .../item/domain/usecases/managers/index-item.manager.ts | 9 +++++++++ .../item/infrastructure/dto/filter-item.dto.ts | 6 ++++++ 2 files changed, 15 insertions(+) diff --git a/src/modules/item-related/item/domain/usecases/managers/index-item.manager.ts b/src/modules/item-related/item/domain/usecases/managers/index-item.manager.ts index 41c12a3..28ef6f9 100644 --- a/src/modules/item-related/item/domain/usecases/managers/index-item.manager.ts +++ b/src/modules/item-related/item/domain/usecases/managers/index-item.manager.ts @@ -106,6 +106,15 @@ export class IndexItemManager extends BaseIndexManager { queryBuilder.andWhere(`${this.tableName}.tenant_id Is Null`); } + if (this.filterParam.time_group_ids?.length) { + queryBuilder.andWhere( + `${this.tableName}.time_group_id In (:...timeGroupIds)`, + { + timeGroupIds: this.filterParam.time_group_ids, + }, + ); + } + if (this.filterParam.show_to_booking) { queryBuilder.andWhere(`${this.tableName}.show_to_booking = true`); } diff --git a/src/modules/item-related/item/infrastructure/dto/filter-item.dto.ts b/src/modules/item-related/item/infrastructure/dto/filter-item.dto.ts index b87dc33..be87a1b 100644 --- a/src/modules/item-related/item/infrastructure/dto/filter-item.dto.ts +++ b/src/modules/item-related/item/infrastructure/dto/filter-item.dto.ts @@ -16,6 +16,12 @@ export class FilterItemDto extends BaseFilterDto implements FilterItemEntity { }) season_period_ids: string[]; + @ApiProperty({ type: ['string'], required: false }) + @Transform((body) => { + return Array.isArray(body.value) ? body.value : [body.value]; + }) + time_group_ids: string[]; + @ApiProperty({ type: ['string'], required: false }) @Transform((body) => { return Array.isArray(body.value) ? body.value : [body.value];