add wallet in get user
This commit is contained in:
parent
2e52ae494e
commit
96d5089dc8
|
@ -24,5 +24,6 @@ import { ProductModule } from '../product/product.module';
|
|||
],
|
||||
controllers: [TransactionController, PpobCallbackController],
|
||||
providers: [TransactionService, CoaService],
|
||||
exports:[CoaService]
|
||||
})
|
||||
export class TransactionModule {}
|
||||
|
|
|
@ -3,9 +3,10 @@ import { TypeOrmModule } from '@nestjs/typeorm';
|
|||
import { UsersService } from './users.service';
|
||||
import { UsersController } from './users.controller';
|
||||
import { User } from './entities/user.entity';
|
||||
import { TransactionModule } from 'src/transaction/transaction.module';
|
||||
|
||||
@Module({
|
||||
imports: [TypeOrmModule.forFeature([User])],
|
||||
imports: [TypeOrmModule.forFeature([User]), TransactionModule],
|
||||
controllers: [UsersController],
|
||||
providers: [UsersService],
|
||||
exports: [UsersService],
|
||||
|
|
|
@ -6,12 +6,15 @@ import { User } from './entities/user.entity';
|
|||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
import { randomStringGenerator } from '@nestjs/common/utils/random-string-generator.util';
|
||||
import { hashPassword } from '../helper/hash_password';
|
||||
import { CoaService } from 'src/transaction/coa.service';
|
||||
import { coaType } from 'src/helper/enum-list';
|
||||
|
||||
@Injectable()
|
||||
export class UsersService {
|
||||
constructor(
|
||||
@InjectRepository(User)
|
||||
private usersRepository: Repository<User>,
|
||||
private coaService: CoaService
|
||||
) {}
|
||||
|
||||
async create(createUserDto: CreateUserDto) {
|
||||
|
@ -30,8 +33,13 @@ export class UsersService {
|
|||
}
|
||||
|
||||
async findOne(id: string) {
|
||||
const coa = await this.coaService.findByUser(id,coaType.WALLET);
|
||||
try {
|
||||
return await this.usersRepository.findOneOrFail(id);
|
||||
const userData = await this.usersRepository.findOneOrFail(id);
|
||||
return {
|
||||
...userData,
|
||||
wallet:coa.amount,
|
||||
};
|
||||
} catch (e) {
|
||||
if (e instanceof EntityNotFoundError) {
|
||||
throw new HttpException(
|
||||
|
|
Loading…
Reference in New Issue
Block a user