import { Controller, Get, Post, Body, Patch, Param, Delete, Put, ParseIntPipe, UseGuards, Query, Logger, } from '@nestjs/common'; import { UserService } from './user.service'; import { getCurrentUserId, Public } from '../common/decorators'; import { AtGuard, RtGuard } from '../common/guards'; @Controller('') export class UserController { private readonly logger: Logger = new Logger('user resolver'); constructor(private readonly userService: UserService) {} @Get('cart/all') async getAllCartItems(@getCurrentUserId() userId: number) { return this.userService.getAllCartItems(userId); } @Put('cart/add/:productId') async addToCart( @getCurrentUserId() userId: number, @Param('productId', ParseIntPipe) productId: number, ) { return this.userService.addToCart(userId, productId); } @Put('cart/remove/:productId') async removeFromCart( @getCurrentUserId() userId: number, @Param('productId', ParseIntPipe) productId: number, ) { return this.userService.removeFromCart(userId, productId); } @Delete('cart/:productId') async deleteItem( @getCurrentUserId() userId: number, @Param('productId', ParseIntPipe) productId: number, ) { return this.userService.deleteItem(userId, productId); } }