parent
021e22fcc9
commit
f65fbce4d6
3 changed files with 17 additions and 3 deletions
@ -1,7 +1,15 @@ |
|||||||
import { Injectable } from '@nestjs/common'; |
import { Injectable } from '@nestjs/common'; |
||||||
|
import { InjectModel } from '@nestjs/sequelize'; |
||||||
|
import { Wallet } from './entities/wallet.entity';
|
||||||
|
|
||||||
@Injectable() |
@Injectable() |
||||||
export class WalletService { |
export class WalletService { |
||||||
constructor(){} |
constructor( |
||||||
|
@InjectModel(Wallet) private walletModel: typeof Wallet, |
||||||
|
) {} |
||||||
|
|
||||||
|
async getBalance(userId: number): Promise<number> { |
||||||
|
const wallet = await this.walletModel.findOne({ where: { userId } }); |
||||||
|
return wallet ? wallet.balance : 0; |
||||||
|
} |
||||||
} |
} |
||||||
|
Loading…
Reference in new issue