From 3250a6456be77c083543cd2358b4e1b19ee6caae Mon Sep 17 00:00:00 2001 From: hamid zarghami Date: Tue, 7 Jul 2026 23:08:55 +0330 Subject: [PATCH] move time --- src/reserves/dto/find-reserves-query.dto.ts | 12 +++++++++ src/reserves/reserves.service.ts | 28 +++++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/src/reserves/dto/find-reserves-query.dto.ts b/src/reserves/dto/find-reserves-query.dto.ts index 0025aa2..06356c7 100644 --- a/src/reserves/dto/find-reserves-query.dto.ts +++ b/src/reserves/dto/find-reserves-query.dto.ts @@ -21,4 +21,16 @@ export class FindReservesQueryDto { @IsOptional() @IsDateString() appointmentDate?: string; + + @IsOptional() + @IsDateString() + appointmentDateFrom?: string; + + @IsOptional() + @IsDateString() + appointmentDateTo?: string; + + @IsOptional() + @IsUUID() + serviceId?: string; } diff --git a/src/reserves/reserves.service.ts b/src/reserves/reserves.service.ts index 2366633..2d24381 100644 --- a/src/reserves/reserves.service.ts +++ b/src/reserves/reserves.service.ts @@ -132,6 +132,34 @@ export class ReservesService { appointmentDate: query.appointmentDate, }); } + if (query.appointmentDateFrom && query.appointmentDateTo) { + qb.andWhere( + 'reserve.appointmentDate BETWEEN :appointmentDateFrom AND :appointmentDateTo', + { + appointmentDateFrom: query.appointmentDateFrom, + appointmentDateTo: query.appointmentDateTo, + }, + ); + } else if (query.appointmentDateFrom) { + qb.andWhere('reserve.appointmentDate >= :appointmentDateFrom', { + appointmentDateFrom: query.appointmentDateFrom, + }); + } else if (query.appointmentDateTo) { + qb.andWhere('reserve.appointmentDate <= :appointmentDateTo', { + appointmentDateTo: query.appointmentDateTo, + }); + } + if (query.serviceId) { + qb.andWhere( + `EXISTS ( + SELECT 1 + FROM reserve_items serviceFilterItem + WHERE serviceFilterItem."reserveId" = reserve.id + AND serviceFilterItem."serviceId" = :serviceId + )`, + { serviceId: query.serviceId }, + ); + } if (!this.authorizationService.isAdmin(user)) { if (user.role === UserRole.SALON) {