scheduale
This commit is contained in:
@@ -23,12 +23,12 @@ import { RestId } from 'src/common/decorators/rest-id.decorator';
|
|||||||
export class ScheduleController {
|
export class ScheduleController {
|
||||||
constructor(private readonly scheduleService: ScheduleService) {}
|
constructor(private readonly scheduleService: ScheduleService) {}
|
||||||
|
|
||||||
@Get('public/schedules/restaurant/:slug/today')
|
@Get('public/schedules/restaurant/:slug')
|
||||||
@ApiOperation({ summary: 'Get today schedule of a restaurant' })
|
@ApiOperation({ summary: 'Get schedule of a restaurant by slug' })
|
||||||
@ApiParam({ name: 'slug', description: 'Restaurant Slug' })
|
@ApiParam({ name: 'slug', description: 'Restaurant Slug' })
|
||||||
@ApiOkResponse({ description: 'Today schedule of the restaurant', type: Schedule })
|
@ApiOkResponse({ description: 'Today schedule of the restaurant', type: Schedule })
|
||||||
async getTodaySchedules(@Param('slug') slug: string): Promise<Schedule | null> {
|
async getTodaySchedules(@Param('slug') slug: string): Promise<Schedule[]> {
|
||||||
return this.scheduleService.findTodaySchedules(slug);
|
return this.scheduleService.findScheduleBySlug(slug);
|
||||||
}
|
}
|
||||||
|
|
||||||
@UseGuards(AdminAuthGuard)
|
@UseGuards(AdminAuthGuard)
|
||||||
|
|||||||
@@ -65,6 +65,20 @@ export class ScheduleService {
|
|||||||
return this.scheduleRepository.findOne(where);
|
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> {
|
async findOne(id: string, restId: string): Promise<Schedule> {
|
||||||
const schedule = await this.scheduleRepository.findOne({ id, restId });
|
const schedule = await this.scheduleRepository.findOne({ id, restId });
|
||||||
if (!schedule) {
|
if (!schedule) {
|
||||||
|
|||||||
Reference in New Issue
Block a user