import { Controller , Get , Post , Body , Query , Next , Headers , UseGuards , ParseIntPipe , } from '@nestjs/common' ; import { TagService } from '../service/tag.service' ; import { UserGuard } from '../../../common/guards/user.guard' ; import { CreateTagDto } from '../form/create_tag.dto' ; import { Auth } from '../../../common/interface/Auth' ; import { UpdateTagDto } from '../form/update_tag.dto' ; import { SuccessResponse } from '../../../common/filters/successResponse' ; @ Controller ( 'tag/user' ) export class UserController { constructor ( private readonly tagService ) { } @ UseGuards ( UserGuard ) @ Post ( '/create-tag' ) async createTag ( @ Body ( ) crateTagDto , @ Headers ( 'auth' ) auth ) { const data = new CreateTagDto ( crateTagDto ) ; await data . validate ( ) ; return this . tagService . createTag ( data , auth . user_id ) ; } @ UseGuards ( UserGuard ) @ Post ( '/update-tag' ) async updateTag ( @ Body ( ) updateTagDto , @ Headers ( 'auth' ) auth ) { const data = new UpdateTagDto ( updateTagDto ) ; await data . validate ( ) ; return this . tagService . updateTag ( data , auth . user_id ) ; } @ UseGuards ( UserGuard ) @ Get ( '/delete-tag' ) async daleteTag ( @ Query ( 'tag_id' ) tagId , @ Headers ( 'auth' ) auth ) { await this . tagService . daleteTag ( tagId , auth . user_id ) ; return SuccessResponse ; } @ UseGuards ( UserGuard ) @ Get ( 'list' ) async getList ( @ Headers ( 'auth' ) auth , @ Query ( 'page' , new ParseIntPipe ( ) ) page , @ Query ( 'size' , new ParseIntPipe ( ) ) size ) { return this . tagService . getList ( page , size , auth . user_id ) ; } }