category
This commit is contained in:
@@ -7,6 +7,8 @@ import { CreateScheduleDto } from '../dto/create-schedule.dto';
|
||||
import { UpdateScheduleDto } from '../dto/update-schedule.dto';
|
||||
import { FindSchedulesDto } from '../dto/find-schedules.dto';
|
||||
import { RestRepository } from '../repositories/rest.repository';
|
||||
import { Restaurant } from '../entities/restaurant.entity';
|
||||
import { RestMessage } from 'src/common/enums/message.enum';
|
||||
// import { RestMessage } from 'src/common/enums/message.enum';
|
||||
|
||||
@Injectable()
|
||||
@@ -46,12 +48,16 @@ export class ScheduleService {
|
||||
return this.scheduleRepository.find(where, { orderBy: { weekDay: 'asc' } });
|
||||
}
|
||||
|
||||
async findTodaySchedules(restId: string): Promise<Schedule | null> {
|
||||
async findTodaySchedules(slug: string): Promise<Schedule | null> {
|
||||
const restaurant = await this.em.findOne(Restaurant, { slug });
|
||||
if (!restaurant) {
|
||||
throw new NotFoundException(RestMessage.NOT_FOUND);
|
||||
}
|
||||
const today = new Date();
|
||||
const weekDay = today.getDay(); // 0 = Sunday, 6 = Saturday
|
||||
|
||||
const where: FilterQuery<Schedule> = {
|
||||
restId,
|
||||
restId: restaurant.id.toString(),
|
||||
weekDay,
|
||||
isActive: true,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user