xiongzhu 2 anni fa
parent
commit
7f30f78dd9
2 ha cambiato i file con 3 aggiunte e 3 eliminazioni
  1. 2 2
      src/user-balance/user-balance.service.ts
  2. 1 1
      src/utils/common.ts

+ 2 - 2
src/user-balance/user-balance.service.ts

@@ -1,4 +1,4 @@
-import { Injectable, InternalServerErrorException, Logger } from '@nestjs/common'
+import { BadRequestException, Injectable, InternalServerErrorException, Logger } from '@nestjs/common'
 import { InjectRepository } from '@nestjs/typeorm'
 import { UserBalance } from './entities/user-balance.entity'
 import { Repository } from 'typeorm'
@@ -31,7 +31,7 @@ export class UserBalanceService {
         const userBalance = await this.getBalance(userId)
         const balance = userBalance.balance.plus(amount)
         if (balance.comparedTo(new BigNumber(0)) < 0) {
-            throw new Error('余额不足')
+            throw new BadRequestException('余额不足')
         }
         Logger.log(userBalance.balance.plus(amount), '余额')
         await this.balanceRecordRepository.save(

+ 1 - 1
src/utils/common.ts

@@ -1,3 +1,3 @@
 export function hideSensitiveData(str: string) {
-    return str.replace(/(?<=.).(?=.*.)/g, '*')
+    return str.replace(/(?<=^.).*(?=.$)/, '***')
 }