scheduale
This commit is contained in:
@@ -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<Schedule | null> {
|
||||
return this.scheduleService.findTodaySchedules(slug);
|
||||
async getTodaySchedules(@Param('slug') slug: string): Promise<Schedule[]> {
|
||||
return this.scheduleService.findScheduleBySlug(slug);
|
||||
}
|
||||
|
||||
@UseGuards(AdminAuthGuard)
|
||||
|
||||
@@ -65,6 +65,20 @@ export class ScheduleService {
|
||||
return this.scheduleRepository.findOne(where);
|
||||
}
|
||||
|
||||
async findScheduleBySlug(slug: string): Promise<Schedule[]> {
|
||||
const restaurant = await this.em.findOne(Restaurant, { slug });
|
||||
if (!restaurant) {
|
||||
throw new NotFoundException(RestMessage.NOT_FOUND);
|
||||
}
|
||||
|
||||
const where: FilterQuery<Schedule> = {
|
||||
restId: restaurant.id.toString(),
|
||||
isActive: true,
|
||||
};
|
||||
|
||||
return this.scheduleRepository.find(where);
|
||||
}
|
||||
|
||||
async findOne(id: string, restId: string): Promise<Schedule> {
|
||||
const schedule = await this.scheduleRepository.findOne({ id, restId });
|
||||
if (!schedule) {
|
||||
|
||||
Reference in New Issue
Block a user