parent
021e22fcc9
commit
f65fbce4d6
3 changed files with 17 additions and 3 deletions
@ -1,7 +1,15 @@ |
||||
import { Injectable } from '@nestjs/common'; |
||||
|
||||
import { InjectModel } from '@nestjs/sequelize'; |
||||
import { Wallet } from './entities/wallet.entity';
|
||||
|
||||
@Injectable() |
||||
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