mirror of
https://github.com/dadosfera/maestro.git
synced 2026-10-27 00:59:08 +00:00
FEAT: User module init
This commit is contained in:
@@ -0,0 +1,68 @@
|
||||
import {
|
||||
Body,
|
||||
Controller,
|
||||
Delete,
|
||||
Get,
|
||||
Inject,
|
||||
Put,
|
||||
Query,
|
||||
} from '@nestjs/common';
|
||||
import { ApiOkResponse, ApiTags } from '@nestjs/swagger';
|
||||
import { DadosferaLogger } from 'dadosfera-logs';
|
||||
import { RequestUser, User } from 'src/authentication/user.decorator';
|
||||
import {
|
||||
AssignRoleToUserReq,
|
||||
GetAllUsersByCustomerIdReq,
|
||||
GetAllUsersByCustomerIdRes,
|
||||
UnassignRoleToUserReq,
|
||||
} from './dtos/entities';
|
||||
import { UsersService } from './users.service';
|
||||
|
||||
@ApiTags('Users')
|
||||
@Controller('users')
|
||||
export class UsersController {
|
||||
logger: any;
|
||||
|
||||
constructor(
|
||||
@Inject(DadosferaLogger)
|
||||
dadosferaLogger: DadosferaLogger,
|
||||
private userService: UsersService,
|
||||
) {
|
||||
this.logger = dadosferaLogger.logger;
|
||||
}
|
||||
|
||||
@Get()
|
||||
@ApiOkResponse({
|
||||
type: GetAllUsersByCustomerIdRes,
|
||||
description: 'List of users of a customer',
|
||||
})
|
||||
async getAllUsersByCustomerId(
|
||||
@User() user: RequestUser,
|
||||
@Query('s') s: GetAllUsersByCustomerIdReq,
|
||||
) {
|
||||
this.logger.info('getAllUsersByCustomerId', { user });
|
||||
return await this.userService.findAllUsersByCustomerId(user.customer_id, s);
|
||||
}
|
||||
|
||||
@Put('role')
|
||||
async assignRoleToUser(@User() user, @Body() body: AssignRoleToUserReq) {
|
||||
this.logger.info('assignRoleToUser', { user });
|
||||
return await this.userService.assignRoleToUser(body);
|
||||
}
|
||||
|
||||
@Delete('role')
|
||||
async unassignRoleToUser(@User() user, @Body() body: UnassignRoleToUserReq) {
|
||||
this.logger.info('unassignRoleToUser', { user });
|
||||
return await this.userService.unassignRoleToUser(body);
|
||||
}
|
||||
|
||||
// @Get('search')
|
||||
// @ApiOkResponse({ type: SearchUserRes })
|
||||
// async searchUser(
|
||||
// @User() user: RequestUser,
|
||||
// @Query('s') searchQuery: SearchUserReq,
|
||||
// ) {
|
||||
// this.logger.info('searchUser', { user });
|
||||
// console.log(searchQuery);
|
||||
// }
|
||||
}
|
||||
Reference in New Issue
Block a user