diff --git a/src/modules/foods/controllers/food.controller.ts b/src/modules/foods/controllers/food.controller.ts index 2cd3662..097bd7a 100644 --- a/src/modules/foods/controllers/food.controller.ts +++ b/src/modules/foods/controllers/food.controller.ts @@ -6,9 +6,6 @@ import { FindFoodsDto } from '../dto/find-foods.dto'; import { ApiTags, ApiOperation, - ApiCreatedResponse, - ApiOkResponse, - ApiNotFoundResponse, ApiQuery, ApiBody, ApiParam, diff --git a/src/modules/foods/providers/food.service.ts b/src/modules/foods/providers/food.service.ts index 9aa4334..2972052 100644 --- a/src/modules/foods/providers/food.service.ts +++ b/src/modules/foods/providers/food.service.ts @@ -15,15 +15,11 @@ import { Inventory } from 'src/modules/inventory/entities/inventory.entity'; @Injectable() export class FoodService { - private readonly FOODS_BY_RESTAURANT_CACHE_KEY_PREFIX = 'foods:restaurant:'; - private readonly FOODS_CACHE_TTL = 600; // 10 minutes in seconds - constructor( private readonly foodRepository: FoodRepository, private readonly categoryRepository: CategoryRepository, private readonly restRepository: RestRepository, private readonly em: EntityManager, - private readonly cacheService: CacheService, ) { } async create(restId: string, createFoodDto: CreateFoodDto) { @@ -105,7 +101,7 @@ export class FoodService { * Admin food detail (scoped to the authenticated restaurant). */ async findAdminById(restId: string, id: string): Promise { - const food = await this.foodRepository.findOne({ id, restaurant: { id: restId } }, { populate: ['category','inventory'] }); + const food = await this.foodRepository.findOne({ id, restaurant: { id: restId } }, { populate: ['category', 'inventory'] }); if (!food) throw new NotFoundException(FoodMessage.NOT_FOUND); return food; @@ -127,11 +123,14 @@ export class FoodService { const queryFilter: FilterQuery = { restaurant: { slug }, isActive: true, - // weekDays: { $contains: iranWeekDay }, - // ...(mealType ? { mealTypes: { $contains: mealType } } : {}), + weekDays: { $contains: iranWeekDay }, + ...(mealType ? { mealTypes: { $contains: mealType } } : {}), } as unknown as FilterQuery; - return this.foodRepository.find(queryFilter, { populate: ['category'] }); + return this.foodRepository.find(queryFilter, { + populate: ['category'], + orderBy: { order: 'asc' } + }); } /** @@ -261,7 +260,7 @@ export class FoodService { } - async getMyFavorites(userId: string,restId: string) { + async getMyFavorites(userId: string, restId: string) { return this.em.find(Favorite, { user: userId, food: { restaurant: { id: restId } } }, { populate: ['food'] }); } /** diff --git a/src/modules/foods/repositories/food.repository.ts b/src/modules/foods/repositories/food.repository.ts index a731dd9..3957061 100644 --- a/src/modules/foods/repositories/food.repository.ts +++ b/src/modules/foods/repositories/food.repository.ts @@ -24,7 +24,7 @@ export class FoodRepository extends EntityRepository { * Supports: search (title/content), categoryId, isActive, ordering. */ async findAllPaginated(restId: string, opts: FindFoodsOpts = {}): Promise> { - const { page = 1, limit = 10, search, orderBy = 'order', order = 'ASC', categoryId, isActive } = opts; + const { page = 1, limit = 10, search, orderBy = 'order', order = 'asc', categoryId, isActive } = opts; const offset = (page - 1) * limit;