Create wallet module and models

master
nicekid1 2 months ago
parent b0c858c151
commit 021e22fcc9
  1. 2
      src/app.module.ts
  2. 15
      src/wallet/entities/wallet.entity.ts
  3. 8
      src/wallet/wallet.controller.ts
  4. 9
      src/wallet/wallet.module.ts
  5. 7
      src/wallet/wallet.service.ts

@ -7,6 +7,7 @@ import { databaseConfig } from "./config/database.config";
import { UsersModule } from './users/users.module';
import { ProductsModule } from './products/products.module';
import { CartModule } from './cart/cart.module';
import { WalletModule } from './wallet/wallet.module';
@Module({
imports: [
@ -17,6 +18,7 @@ import { CartModule } from './cart/cart.module';
UsersModule,
ProductsModule,
CartModule,
WalletModule,
],
controllers: [AppController],
providers: [AppService],

@ -0,0 +1,15 @@
import { Model, Table, Column, ForeignKey, BelongsTo } from 'sequelize-typescript';
import { User } from '../../users/entities/user.entity';
@Table
export class Wallet extends Model<Wallet> {
@ForeignKey(() => User)
@Column
userId: number;
@BelongsTo(() => User)
user: User;
@Column
balance: number;
}

@ -0,0 +1,8 @@
import { Controller, Get, Post, Body, Patch, Param, Delete } from '@nestjs/common';
import { WalletService } from './wallet.service';
@Controller('wallet')
export class WalletController {
constructor(private readonly walletService: WalletService) {}
}

@ -0,0 +1,9 @@
import { Module } from '@nestjs/common';
import { WalletService } from './wallet.service';
import { WalletController } from './wallet.controller';
@Module({
controllers: [WalletController],
providers: [WalletService],
})
export class WalletModule {}

@ -0,0 +1,7 @@
import { Injectable } from '@nestjs/common';
@Injectable()
export class WalletService {
constructor(){}
}
Loading…
Cancel
Save