|
|
|
@ -1,13 +1,13 @@ |
|
|
|
|
import { Controller, Get, Post, Body, Param, Delete, Query, Put, UseGuards, Request, Patch, HttpException, HttpStatus } from "@nestjs/common"; |
|
|
|
|
import { InjectModel } from "@nestjs/sequelize"; |
|
|
|
|
import { ShopService } from "./shop.service"; |
|
|
|
|
import { Product } from "./entities/product.entity"; |
|
|
|
|
import { CreateProductDto } from "./dto/products/create-product.dto"; |
|
|
|
|
import { UpdateProductDto } from "./dto/products/update-product.dto"; |
|
|
|
|
import { RoleGuard } from "src/users/guard/role.guard"; |
|
|
|
|
import { AddToCartDto } from "./dto/cart/add-to-cart.dto"; |
|
|
|
|
import { JwtAuthGuard } from "src/users/guard/auth.guard"; |
|
|
|
|
import { CreateProductDto } from "./dto/products/create-product.dto"; |
|
|
|
|
import { UpdateProductDto } from "./dto/products/update-product.dto"; |
|
|
|
|
import { UpdateCartDto } from "./dto/cart/update-cart.dto"; |
|
|
|
|
import { InjectModel } from "@nestjs/sequelize"; |
|
|
|
|
import { AddToCartDto } from "./dto/cart/add-to-cart.dto"; |
|
|
|
|
import { Product } from "./entities/product.entity"; |
|
|
|
|
import { Transaction } from "./entities/transaction.entity"; |
|
|
|
|
import { Payment } from "./entities/payment.entity"; |
|
|
|
|
|
|
|
|
@ -54,12 +54,12 @@ export class ShopController { |
|
|
|
|
//delete a product (admin)
|
|
|
|
|
@UseGuards(RoleGuard) |
|
|
|
|
@Delete("product/:id") |
|
|
|
|
async remove(@Param("id") id: string): Promise<{ message: string }> { |
|
|
|
|
async remove(@Param("id") id: string){ |
|
|
|
|
return this.shopService.remove(id); |
|
|
|
|
} |
|
|
|
|
////////////////////////////////////////cart////////////////////////////////////////
|
|
|
|
|
//create and a item to cart (user)
|
|
|
|
|
@UseGuards(JwtAuthGuard) |
|
|
|
|
@UseGuards(JwtAuthGuard)
|
|
|
|
|
@Post("cart") |
|
|
|
|
async createAndAddItemToCart(@Body() addToCartDto: AddToCartDto, @Request() req: any) { |
|
|
|
|
const userId = req.user.id; |
|
|
|
@ -211,7 +211,7 @@ export class ShopController { |
|
|
|
|
async getInvoices() { |
|
|
|
|
return this.shopService.getInvoices(); |
|
|
|
|
} |
|
|
|
|
//get specific user invoices
|
|
|
|
|
//get specific user invoices (admin)
|
|
|
|
|
@UseGuards(RoleGuard) |
|
|
|
|
@Get('invoice/:id') |
|
|
|
|
async getUserInvoice(@Param('id') id:number) { |
|
|
|
|