diff --git a/src/modules/restaurants/controllers/schedule.controller.ts b/src/modules/restaurants/controllers/schedule.controller.ts index a459b0a..c593916 100644 --- a/src/modules/restaurants/controllers/schedule.controller.ts +++ b/src/modules/restaurants/controllers/schedule.controller.ts @@ -23,12 +23,12 @@ import { RestId } from 'src/common/decorators/rest-id.decorator'; export class ScheduleController { constructor(private readonly scheduleService: ScheduleService) {} - @Get('public/schedules/restaurant/:slug/today') - @ApiOperation({ summary: 'Get today schedule of a restaurant' }) + @Get('public/schedules/restaurant/:slug') + @ApiOperation({ summary: 'Get schedule of a restaurant by slug' }) @ApiParam({ name: 'slug', description: 'Restaurant Slug' }) @ApiOkResponse({ description: 'Today schedule of the restaurant', type: Schedule }) - async getTodaySchedules(@Param('slug') slug: string): Promise { - return this.scheduleService.findTodaySchedules(slug); + async getTodaySchedules(@Param('slug') slug: string): Promise { + return this.scheduleService.findScheduleBySlug(slug); } @UseGuards(AdminAuthGuard) diff --git a/src/modules/restaurants/providers/schedule.service.ts b/src/modules/restaurants/providers/schedule.service.ts index b364bcb..2955046 100644 --- a/src/modules/restaurants/providers/schedule.service.ts +++ b/src/modules/restaurants/providers/schedule.service.ts @@ -65,6 +65,20 @@ export class ScheduleService { return this.scheduleRepository.findOne(where); } + async findScheduleBySlug(slug: string): Promise { + const restaurant = await this.em.findOne(Restaurant, { slug }); + if (!restaurant) { + throw new NotFoundException(RestMessage.NOT_FOUND); + } + + const where: FilterQuery = { + restId: restaurant.id.toString(), + isActive: true, + }; + + return this.scheduleRepository.find(where); + } + async findOne(id: string, restId: string): Promise { const schedule = await this.scheduleRepository.findOne({ id, restId }); if (!schedule) {