This commit is contained in:
2025-11-16 10:37:03 +03:30
parent ad4b2e2c89
commit fae765e05a
8 changed files with 45 additions and 30 deletions
@@ -1,4 +1,4 @@
import { Controller, Get, Post, Body, Patch, Param, Delete, Query } from '@nestjs/common';
import { Controller, Get, Post, Body, Patch, Param, Delete, Query, UseGuards } from '@nestjs/common';
import { FoodService } from '../providers/food.service';
import { CreateFoodDto } from '../dto/create-food.dto';
import { UpdateFoodDto } from '../dto/update-food.dto';
@@ -14,7 +14,10 @@ import {
ApiBody,
ApiParam,
} from '@nestjs/swagger';
import { AdminAuthGuard } from 'src/modules/auth/guards/adminAuth.guard';
import { RestId } from 'src/common/decorators';
@UseGuards(AdminAuthGuard)
@ApiTags('foods')
@Controller('foods')
export class FoodController {
@@ -24,8 +27,8 @@ export class FoodController {
@ApiOperation({ summary: 'Create a new food' })
@ApiCreatedResponse({ description: 'The food has been successfully created.', type: CreateFoodDto })
@ApiBody({ type: CreateFoodDto })
create(@Body() createFoodDto: CreateFoodDto) {
return this.foodsService.create(createFoodDto);
create(@Body() createFoodDto: CreateFoodDto, @RestId() restId: string) {
return this.foodsService.create(restId, createFoodDto);
}
@Get()
@@ -38,8 +41,8 @@ export class FoodController {
@ApiQuery({ name: 'order', required: false, enum: ['asc', 'desc'] })
@ApiQuery({ name: 'categoryId', required: false, type: String })
@ApiQuery({ name: 'isActive', required: false, type: Boolean })
findAll(@Query() dto: FindFoodsDto) {
return this.foodsService.findAll(dto);
findAll(@Query() dto: FindFoodsDto,@RestId() restId: string) {
return this.foodsService.findAll(restId, dto);
}
@Get(':id')