From e499a8a1e684d9337e42a3b8329cc5d1c0217434 Mon Sep 17 00:00:00 2001 From: ilham Date: Mon, 20 Dec 2021 15:14:01 +0700 Subject: [PATCH] add: saldo deposit in get member --- src/transaction/entities/coa.entity.ts | 2 ++ src/users/users.service.ts | 14 ++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/src/transaction/entities/coa.entity.ts b/src/transaction/entities/coa.entity.ts index 23de4f0..f60bb7a 100644 --- a/src/transaction/entities/coa.entity.ts +++ b/src/transaction/entities/coa.entity.ts @@ -17,11 +17,13 @@ export class COA extends BaseModel { amount: number; @Column({ + type: 'uuid', nullable: true, }) user: string; @Column({ + type: 'uuid', nullable: true, }) relatedUser: string; diff --git a/src/users/users.service.ts b/src/users/users.service.ts index 987c3bb..eb97d80 100644 --- a/src/users/users.service.ts +++ b/src/users/users.service.ts @@ -126,6 +126,12 @@ export class UsersService { 'user_detail', `user_detail.user = user.id`, ) + .leftJoinAndMapOne( + 'user.coa', + COA, + 'coa', + `coa.user = user.id and coa.type = '0'`, + ) .select([ 'user.id', 'user.username', @@ -133,6 +139,7 @@ export class UsersService { 'roles.id', 'roles.name', 'user_detail', + 'coa.amount', ]); const data = await baseQuery @@ -175,6 +182,12 @@ export class UsersService { 'user_detail', `user_detail.user = user.id`, ) + .leftJoinAndMapOne( + 'user.coa', + COA, + 'coa', + `coa.user = user.id and coa.type = '0'`, + ) .select([ 'user.id', 'user.username', @@ -182,6 +195,7 @@ export class UsersService { 'roles.id', 'roles.name', 'user_detail', + 'coa.amount', ]); const data = await baseQuery