This commit is contained in:
2025-11-25 10:08:34 +03:30
parent a5992d8e29
commit d737b3dc24
7 changed files with 64 additions and 63 deletions
@@ -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,
};