File size: 1,161 Bytes
bac00ce
9e8f9e3
 
 
 
 
bac00ce
9e8f9e3
 
 
 
 
 
 
 
 
 
 
 
bac00ce
 
 
 
 
 
 
 
439f1c8
9e8f9e3
439f1c8
 
b2556e4
9e8f9e3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import { Body, Controller, Get, Post, Put, Query, Request } from '@nestjs/common';
import { UserService } from './user.service.js';
import { UserEntity } from 'src/entities/user.entity.js';
import { Roles } from '../authentication/authorization/roles.decorator.js';
import { Role } from '../../common/enums/role.enum.js';
import { Paginate, PaginateQuery } from 'nestjs-paginate';
import { UpdateUsersDto } from './dto/update-users.dto.js';

@Controller('users')
export class UsersController {
  constructor(private readonly usersService: UserService) {}

  @Post('updateUser')
  async updateUser(@Request() req){
      const userId = req.user.sub;
      const updateUserDto = req.body;
      return this.usersService.updateUserById(userId, updateUserDto);
  }

  @Put('updateList')
  @Roles(Role.ADMIN)
  async updateUsers(

    @Body() updateUsersDto: UpdateUsersDto[],

  ) {
    return this.usersService.updateUsers(updateUsersDto);
  }

  @Get('getUsers')
  @Roles(Role.ADMIN, Role.AREA_MANAGER, Role.BRANCH_MANAGER)
  async getUsers( @Paginate() query: PaginateQuery, ) {
    return this.usersService.getUsers(query);
  }
}