AnhLedger's picture
see list of user
439f1c8
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);
}
}