parent
c7d27edc10
commit
199c2b35a2
6 changed files with 59 additions and 13 deletions
@ -0,0 +1,8 @@ |
||||
import { Controller, Get, Post, Body, Patch, Param, Delete } from '@nestjs/common'; |
||||
import { CartService } from './cart.service'; |
||||
|
||||
@Controller('cart') |
||||
export class CartController { |
||||
constructor(private readonly cartService: CartService) {} |
||||
|
||||
} |
@ -0,0 +1,12 @@ |
||||
import { Module } from "@nestjs/common"; |
||||
import { CartService } from "./cart.service"; |
||||
import { CartController } from "./cart.controller"; |
||||
import { Cart } from "./entities/cart.entity"; |
||||
import { SequelizeModule } from "@nestjs/sequelize"; |
||||
|
||||
@Module({ |
||||
imports: [SequelizeModule.forFeature([Cart])], |
||||
controllers: [CartController], |
||||
providers: [CartService], |
||||
}) |
||||
export class CartModule {} |
@ -0,0 +1,7 @@ |
||||
import { Injectable } from '@nestjs/common'; |
||||
|
||||
|
||||
@Injectable() |
||||
export class CartService { |
||||
|
||||
} |
@ -0,0 +1,23 @@ |
||||
import { Model, Table, Column, ForeignKey, BelongsTo } from "sequelize-typescript"; |
||||
import { User } from "../../users/entities/user.entity"; |
||||
import { Product } from "../../products/entities/product.entity"; |
||||
|
||||
@Table |
||||
export class Cart extends Model<Cart> { |
||||
@ForeignKey(() => User) |
||||
@Column |
||||
userId: number; |
||||
|
||||
@BelongsTo(() => User) |
||||
user: User; |
||||
|
||||
@ForeignKey(() => Product) |
||||
@Column |
||||
productId: number; |
||||
|
||||
@BelongsTo(() => Product) |
||||
product: Product; |
||||
|
||||
@Column |
||||
quantity: number; |
||||
} |
Loading…
Reference in new issue