fix: add user deetail in get all user
This commit is contained in:
		| @@ -24,6 +24,7 @@ import { RoleService } from 'src/configurable/roles.service'; | ||||
| import { InputCoaDto } from 'src/transaction/dto/input-coa.dto'; | ||||
| import * as uuid from 'uuid'; | ||||
| import { UserDetail } from './entities/user_detail.entity'; | ||||
| import { COA } from '../transaction/entities/coa.entity'; | ||||
|  | ||||
| @Injectable() | ||||
| export class UsersService { | ||||
| @@ -112,17 +113,38 @@ export class UsersService { | ||||
|     return userData; | ||||
|   } | ||||
|  | ||||
|   findAll(page: number, id: string) { | ||||
|     return this.usersRepository.findAndCount({ | ||||
|       skip: page * 10, | ||||
|       take: 10, | ||||
|       order: { | ||||
|         version: 'DESC', | ||||
|       }, | ||||
|       where: { | ||||
|         id: Not(Equal(id)), | ||||
|       }, | ||||
|     }); | ||||
|   async findAll(page: number, id: string) { | ||||
|     const baseQuery = this.usersRepository | ||||
|       .createQueryBuilder('user') | ||||
|       .where('user.id != :id', { | ||||
|         id: id, | ||||
|       }) | ||||
|       .leftJoinAndSelect('user.roles', 'roles', `roles.id = user.roles_id`) | ||||
|       .leftJoinAndMapOne( | ||||
|         'user.user_detail', | ||||
|         UserDetail, | ||||
|         'user_detail', | ||||
|         `user_detail.user = user.id`, | ||||
|       ) | ||||
|       .select([ | ||||
|         'user.id', | ||||
|         'user.username', | ||||
|         'user.isActive', | ||||
|         'roles.name', | ||||
|         'user_detail', | ||||
|       ]); | ||||
|  | ||||
|     const data = await baseQuery | ||||
|       .skip(page * 10) | ||||
|       .take(10) | ||||
|       .getMany(); | ||||
|  | ||||
|     const totalData = await baseQuery.getCount(); | ||||
|  | ||||
|     return { | ||||
|       data, | ||||
|       count: totalData, | ||||
|     }; | ||||
|   } | ||||
|  | ||||
|   findByRoles(relationId: string, page: number) { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user