1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- import { JwtGuard } from '@/common/guards';
- import {
- Body,
- Controller,
- Delete,
- Get,
- Param,
- Patch,
- Post,
- Query,
- UseGuards,
- } from '@nestjs/common';
- import { ApiBearerAuth, ApiTags } from '@nestjs/swagger';
- import { CategoryService } from './category.service';
- import { CreateCategoryDto, GetAllCategoryDto, GetCategoryDto, UpdateCategoryDto } from './dto';
- @Controller('category')
- @ApiTags('category')
- @ApiBearerAuth('JWT')
- @UseGuards(JwtGuard)
- export class CategoryController {
- constructor(private readonly categoryService: CategoryService) {}
- @Post()
- create(@Body() createCategoryDto: CreateCategoryDto) {
- return this.categoryService.create(createCategoryDto);
- }
- @Get()
- getAllCategories(@Query() getAllCategoryDto: GetAllCategoryDto) {
- return this.categoryService.findAll(getAllCategoryDto);
- }
- @Get('tree')
- getAllCategoriesTree(@Query() getAllCategoryDto: GetAllCategoryDto) {
- return this.categoryService.findAllWithTree(getAllCategoryDto);
- }
- @Get('page')
- findPagination(@Query() queryDto: GetCategoryDto) {
- return this.categoryService.findPagination(queryDto);
- }
- @Delete(':id')
- remove(@Param('id') id: string) {
- return this.categoryService.remove(+id);
- }
- @Patch(':id')
- update(@Param('id') id: string, @Body() updateCategoryDto: UpdateCategoryDto) {
- return this.categoryService.update(+id, updateCategoryDto);
- }
- }
|