import { Controller, Get, Post, Body, Patch, Param, Delete } from "@nestjs/common"; import { CartService } from "./cart.service"; import { Cart } from "./entities/cart.entity"; @Controller("cart") export class CartController { constructor(private readonly cartService: CartService) {} @Post() async addToCart(@Body() body: { userId: number; productId: number; quantity: number }): Promise<{ message: string; cartItem: Cart }> { const { userId, productId, quantity } = body; const result = await this.cartService.addToCart(userId, productId, quantity); return result; } @Get(':userId') async getUserCart(@Param('userId') userId: number) { return this.cartService.getUserCart(userId); } }