import { Controller , Post , Body , UseGuards , Param , Get , Delete , Patch } from '@nestjs/common' ; import { AuthGuard } from '@nestjs/passport' ; import { ApiTags , ApiBearerAuth } from '@nestjs/swagger' ; import { Roles } from 'src/shared/Decorators/roles.decorator' ; import { CreateCategoryDto } from '../Dto/create-category.dto' ; import { CategoryService } from '../Service/category.service' ; import { UpdateCategoryDto } from '../Dto/update-category.dto' ; import { ISerializeResponse } from 'src/shared/Services/serializer.service' ; import { Role } from 'src/shared/Enums/Roles' ; import { StatusOk } from 'src/shared/Types' ; @ ApiTags ( 'v1/category' ) @ Controller ( ) export class CategoryController { constructor ( private readonly categoryService ) { } @ Get ( ':categoryId' ) getCategory ( @ Param ( 'categoryId' ) categoryId ) { return this . categoryService . getCategory ( categoryId ) ; } @ Get ( 'main-categories' ) getMainCategories ( ) { return this . categoryService . getMainCategories ( ) ; } @ Get ( ':categoryId/child-categories' ) getChildCategories ( @ Param ( 'categoryId' ) categoryId ) { return this . categoryService . getChildCategories ( categoryId ) ; } @ Get ( 'trending-categories' ) getTrendingCategories ( ) { return this . categoryService . getTrendingCategories ( ) ; } @ ApiBearerAuth ( ) @ UseGuards ( AuthGuard ( 'jwt' ) ) @ Post ( ) @ Roles ( Role . SuperAdmin ) createCategory ( @ Body ( ) dto ) { return this . categoryService . createCategory ( dto ) ; } @ ApiBearerAuth ( ) @ UseGuards ( AuthGuard ( 'jwt' ) ) @ Patch ( ':categoryId' ) @ Roles ( Role . SuperAdmin ) updateCategory ( @ Param ( 'categoryId' ) categoryId , @ Body ( ) dto ) { return this . categoryService . updateCategory ( categoryId , dto ) ; } @ ApiBearerAuth ( ) @ UseGuards ( AuthGuard ( 'jwt' ) ) @ Delete ( ':categoryId' ) @ Roles ( Role . SuperAdmin ) deleteCategory ( @ Param ( 'categoryId' ) categoryId ) { return this . categoryService . deleteCategory ( categoryId ) ; } }