import { Controller, Get, Post, Body, Patch, Param, Delete, Query, ParseIntPipe, DefaultValuePipe, UseGuards, } from '@nestjs/common'; import { {{pascal}}sService } from './{{plural}}.service'; import { Create{{pascal}}Dto } from './dto/create-{{singular}}.dto'; import { Update{{pascal}}Dto } from './dto/update-{{singular}}.dto'; import { Query{{pascal}}Dto } from './dto/query-{{singular}}.dto'; import { JwtAuthGuard } from '../auth/jwt-auth.guard'; import { Roles } from '../auth/roles.decorator'; import { Role } from '../auth/role.enum'; import { RolesGuard } from '../auth/roles.guard'; @Controller('{{plural}}') @UseGuards(JwtAuthGuard, RolesGuard) @Roles(Role.Admin) export class {{pascal}}sController { constructor(private readonly {{camel}}sService: {{pascal}}sService) {} @Post() create(@Body() create{{pascal}}Dto: Create{{pascal}}Dto) { return this.{{camel}}sService.create(create{{pascal}}Dto); } @Get() findAll(@Query() queryParams: Query{{pascal}}Dto) { return this.{{camel}}sService.findAll(queryParams); } @Get('search') search( @Query('q') term: string, @Query('page', new DefaultValuePipe(1), ParseIntPipe) page: number, @Query('limit', new DefaultValuePipe(10), ParseIntPipe) limit: number, ) { return this.{{camel}}sService.search(term, { page, limit }); } @Get(':id') findOne(@Param('id', ParseIntPipe) id: number) { return this.{{camel}}sService.findOne(id); } @Patch(':id') update(@Param('id', ParseIntPipe) id: number, @Body() update{{pascal}}Dto: Update{{pascal}}Dto) { return this.{{camel}}sService.update(id, update{{pascal}}Dto); } @Delete(':id') remove(@Param('id', ParseIntPipe) id: number) { return this.{{camel}}sService.remove(id); } }