Merge branch 'development' into 'devops-staging'
feat: rearrangement find one user api service See merge request empatnusabangsa/ppob/ppob-backend!57
This commit is contained in:
		@@ -1,10 +1,4 @@
 | 
			
		||||
import {
 | 
			
		||||
  forwardRef,
 | 
			
		||||
  HttpException,
 | 
			
		||||
  HttpStatus,
 | 
			
		||||
  Inject,
 | 
			
		||||
  Injectable,
 | 
			
		||||
} from '@nestjs/common';
 | 
			
		||||
import { forwardRef, HttpException, HttpStatus, Inject, Injectable } from '@nestjs/common';
 | 
			
		||||
import { CreateUserDto } from './dto/create-user.dto';
 | 
			
		||||
import { UpdateUserDto } from './dto/update-user.dto';
 | 
			
		||||
import { Connection, EntityNotFoundError, Not, Repository } from 'typeorm';
 | 
			
		||||
@@ -252,12 +246,28 @@ export class UsersService {
 | 
			
		||||
    const coa = await this.coaService.findByUser(id, coaType.WALLET);
 | 
			
		||||
 | 
			
		||||
    try {
 | 
			
		||||
      const userData = await this.usersRepository.findOneOrFail({
 | 
			
		||||
        where: {
 | 
			
		||||
      const userData = await this.usersRepository
 | 
			
		||||
        .createQueryBuilder('users')
 | 
			
		||||
        .leftJoinAndSelect('users.roles', 'roles')
 | 
			
		||||
        .leftJoinAndSelect('users.superior', 'superior')
 | 
			
		||||
        .leftJoinAndSelect('users.userDetail', 'userDetail')
 | 
			
		||||
        .where('users.id = :id', {
 | 
			
		||||
          id: id,
 | 
			
		||||
        },
 | 
			
		||||
        relations: ['roles', 'superior', 'userDetail'],
 | 
			
		||||
      });
 | 
			
		||||
        })
 | 
			
		||||
        .select([
 | 
			
		||||
          'users.id',
 | 
			
		||||
          'users.username',
 | 
			
		||||
          'users.isActive',
 | 
			
		||||
          'users.createdAt',
 | 
			
		||||
          'roles.id',
 | 
			
		||||
          'roles.name',
 | 
			
		||||
          'superior.id',
 | 
			
		||||
          'superior.username',
 | 
			
		||||
          'userDetail.id',
 | 
			
		||||
          'userDetail.name',
 | 
			
		||||
          'userDetail.phone_number',
 | 
			
		||||
        ])
 | 
			
		||||
        .getOne();
 | 
			
		||||
 | 
			
		||||
      return {
 | 
			
		||||
        ...userData,
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user