From f30b1729d3d85ae87d95ba81837c3248268cb4d2 Mon Sep 17 00:00:00 2001 From: morteza-mortezai Date: Sat, 22 Nov 2025 16:03:03 +0330 Subject: [PATCH] schedule bug --- .../controllers/public-schedule.controller.ts | 15 ++++++++------- .../restaurants/providers/schedule.service.ts | 5 +++-- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/modules/restaurants/controllers/public-schedule.controller.ts b/src/modules/restaurants/controllers/public-schedule.controller.ts index 98e7d36..852ac4f 100644 --- a/src/modules/restaurants/controllers/public-schedule.controller.ts +++ b/src/modules/restaurants/controllers/public-schedule.controller.ts @@ -1,17 +1,18 @@ -import { Controller, Get } from '@nestjs/common'; +import { Controller, Get, Param } from '@nestjs/common'; import { ScheduleService } from '../providers/schedule.service'; import { Schedule } from '../entities/schedule.entity'; -import { ApiTags, ApiOperation, ApiOkResponse } from '@nestjs/swagger'; +import { ApiTags, ApiOperation, ApiOkResponse, ApiParam } from '@nestjs/swagger'; @ApiTags('schedules') @Controller('schedules') export class PublicScheduleController { constructor(private readonly scheduleService: ScheduleService) {} - @Get('today') - @ApiOperation({ summary: 'Get all today schedules of restaurants' }) - @ApiOkResponse({ description: 'List of today schedules', type: [Schedule] }) - async getTodaySchedules(): Promise { - return await this.scheduleService.findTodaySchedules(); + @Get(':restId/today') + @ApiOperation({ summary: 'Get today schedule of a restaurant' }) + @ApiParam({ name: 'restId', description: 'Restaurant ID' }) + @ApiOkResponse({ description: 'Today schedule of the restaurant', type: Schedule }) + async getTodaySchedules(@Param('restId') restId: string): Promise { + return await this.scheduleService.findTodaySchedules(restId); } } diff --git a/src/modules/restaurants/providers/schedule.service.ts b/src/modules/restaurants/providers/schedule.service.ts index 07a0888..6633427 100644 --- a/src/modules/restaurants/providers/schedule.service.ts +++ b/src/modules/restaurants/providers/schedule.service.ts @@ -46,16 +46,17 @@ export class ScheduleService { return this.scheduleRepository.find(where, { orderBy: { weekDay: 'asc' } }); } - async findTodaySchedules(): Promise { + async findTodaySchedules(restId: string): Promise { const today = new Date(); const weekDay = today.getDay(); // 0 = Sunday, 6 = Saturday const where: FilterQuery = { + restId, weekDay, isActive: true, }; - return this.scheduleRepository.find(where, { orderBy: { openTime: 'asc' } }); + return this.scheduleRepository.findOne(where); } async findOne(id: string, restId: string): Promise {