foods
This commit is contained in:
@@ -0,0 +1 @@
|
||||
export class CreateFoodDto {}
|
||||
@@ -0,0 +1,4 @@
|
||||
import { PartialType } from '@nestjs/swagger';
|
||||
import { CreateFoodDto } from './create-food.dto';
|
||||
|
||||
export class UpdateFoodDto extends PartialType(CreateFoodDto) {}
|
||||
@@ -0,0 +1 @@
|
||||
export class Food {}
|
||||
@@ -0,0 +1,34 @@
|
||||
import { Controller, Get, Post, Body, Patch, Param, Delete } from '@nestjs/common';
|
||||
import { FoodsService } from './foods.service';
|
||||
import { CreateFoodDto } from './dto/create-food.dto';
|
||||
import { UpdateFoodDto } from './dto/update-food.dto';
|
||||
|
||||
@Controller('foods')
|
||||
export class FoodsController {
|
||||
constructor(private readonly foodsService: FoodsService) {}
|
||||
|
||||
@Post()
|
||||
create(@Body() createFoodDto: CreateFoodDto) {
|
||||
return this.foodsService.create(createFoodDto);
|
||||
}
|
||||
|
||||
@Get()
|
||||
findAll() {
|
||||
return this.foodsService.findAll();
|
||||
}
|
||||
|
||||
@Get(':id')
|
||||
findOne(@Param('id') id: string) {
|
||||
return this.foodsService.findOne(+id);
|
||||
}
|
||||
|
||||
@Patch(':id')
|
||||
update(@Param('id') id: string, @Body() updateFoodDto: UpdateFoodDto) {
|
||||
return this.foodsService.update(+id, updateFoodDto);
|
||||
}
|
||||
|
||||
@Delete(':id')
|
||||
remove(@Param('id') id: string) {
|
||||
return this.foodsService.remove(+id);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { FoodsService } from './foods.service';
|
||||
import { FoodsController } from './foods.controller';
|
||||
|
||||
@Module({
|
||||
controllers: [FoodsController],
|
||||
providers: [FoodsService],
|
||||
})
|
||||
export class FoodsModule {}
|
||||
@@ -0,0 +1,26 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { CreateFoodDto } from './dto/create-food.dto';
|
||||
import { UpdateFoodDto } from './dto/update-food.dto';
|
||||
|
||||
@Injectable()
|
||||
export class FoodsService {
|
||||
create(createFoodDto: CreateFoodDto) {
|
||||
return 'This action adds a new food';
|
||||
}
|
||||
|
||||
findAll() {
|
||||
return `This action returns all foods`;
|
||||
}
|
||||
|
||||
findOne(id: number) {
|
||||
return `This action returns a #${id} food`;
|
||||
}
|
||||
|
||||
update(id: number, updateFoodDto: UpdateFoodDto) {
|
||||
return `This action updates a #${id} food`;
|
||||
}
|
||||
|
||||
remove(id: number) {
|
||||
return `This action removes a #${id} food`;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user