Loading backend/src/category/category.controller.ts 0 → 100644 +43 −0 Original line number Diff line number Diff line import { Controller, Get, Post, Body, Param, Delete, UseGuards } from '@nestjs/common'; import { CategoryService } from './category.service'; import { AuthAdminGuard } from 'src/auth/admin/authAdmin.guard'; import { Roles } from 'src/auth/role.decorator'; import { SUPERADMIN_ROLES } from 'src/shared/enum/admin-role.enum'; import { ApiBearerAuth, ApiBody, ApiTags } from '@nestjs/swagger'; import { CreateCategoryReqDto } from './dto/create-category-req.dto'; import { LANGUAGES } from 'src/shared/enum/languages.enum'; @Controller('category') @ApiTags('Category') export class CategoryController { constructor(private readonly categoryService: CategoryService) {} @UseGuards(AuthAdminGuard) @Roles(SUPERADMIN_ROLES) @ApiBearerAuth('jwt') @ApiBody({ type: CreateCategoryReqDto }) @Post() create(@Body() createCategoryDto: CreateCategoryReqDto) { this.categoryService.create(createCategoryDto); return { message: 'Category created successfully' }; } @Get(':lang') findAll(@Param('lang') lang: LANGUAGES) { return this.categoryService.findAll(lang); } // @Patch(':id') // update(@Param('id') id: string, @Body() updateCategoryDto: UpdateCategoryDto) { // return this.categoryService.update(+id, updateCategoryDto); // } @UseGuards(AuthAdminGuard) @Roles(SUPERADMIN_ROLES) @ApiBearerAuth('jwt') @Delete(':id') remove(@Param('id') id: string) { this.categoryService.remove(+id); return { message: 'Category deleted successfully' }; } } Loading
backend/src/category/category.controller.ts 0 → 100644 +43 −0 Original line number Diff line number Diff line import { Controller, Get, Post, Body, Param, Delete, UseGuards } from '@nestjs/common'; import { CategoryService } from './category.service'; import { AuthAdminGuard } from 'src/auth/admin/authAdmin.guard'; import { Roles } from 'src/auth/role.decorator'; import { SUPERADMIN_ROLES } from 'src/shared/enum/admin-role.enum'; import { ApiBearerAuth, ApiBody, ApiTags } from '@nestjs/swagger'; import { CreateCategoryReqDto } from './dto/create-category-req.dto'; import { LANGUAGES } from 'src/shared/enum/languages.enum'; @Controller('category') @ApiTags('Category') export class CategoryController { constructor(private readonly categoryService: CategoryService) {} @UseGuards(AuthAdminGuard) @Roles(SUPERADMIN_ROLES) @ApiBearerAuth('jwt') @ApiBody({ type: CreateCategoryReqDto }) @Post() create(@Body() createCategoryDto: CreateCategoryReqDto) { this.categoryService.create(createCategoryDto); return { message: 'Category created successfully' }; } @Get(':lang') findAll(@Param('lang') lang: LANGUAGES) { return this.categoryService.findAll(lang); } // @Patch(':id') // update(@Param('id') id: string, @Body() updateCategoryDto: UpdateCategoryDto) { // return this.categoryService.update(+id, updateCategoryDto); // } @UseGuards(AuthAdminGuard) @Roles(SUPERADMIN_ROLES) @ApiBearerAuth('jwt') @Delete(':id') remove(@Param('id') id: string) { this.categoryService.remove(+id); return { message: 'Category deleted successfully' }; } }