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