feat(scaffold): add src/items/items.controller.ts [skip ci]

This commit is contained in:
2026-05-11 14:48:07 +00:00
parent ef4db6f659
commit 16ea66cb24

View File

@@ -0,0 +1,48 @@
import {
Body,
Controller,
Delete,
Get,
HttpCode,
Param,
ParseIntPipe,
Post,
Put,
} from '@nestjs/common';
import { ItemsService } from './items.service';
class CreateItemDto {
name: string;
description?: string;
}
@Controller('api/items')
export class ItemsController {
constructor(private readonly items: ItemsService) {}
@Get()
findAll() {
return this.items.findAll();
}
@Post()
@HttpCode(201)
create(@Body() dto: CreateItemDto) {
return this.items.create(dto.name, dto.description);
}
@Get(':id')
findOne(@Param('id', ParseIntPipe) id: number) {
return this.items.findOne(id);
}
@Put(':id')
update(@Param('id', ParseIntPipe) id: number, @Body() dto: CreateItemDto) {
return this.items.update(id, dto.name, dto.description);
}
@Delete(':id')
remove(@Param('id', ParseIntPipe) id: number) {
return this.items.remove(id);
}
}