FEAT: Roles WIP

This commit is contained in:
Gabriel Rosa
2022-07-14 10:23:04 -03:00
parent d5cd562860
commit 14cfc46492
15 changed files with 247 additions and 116 deletions
+15 -15
View File
@@ -23,6 +23,7 @@ import {
} from './dtos/entities';
import { UsersService } from './users.service';
// TODO GET de hierarquias e do PATCH em usuário
@ApiTags('Users')
@Controller('users')
export class UsersController {
@@ -54,42 +55,41 @@ export class UsersController {
@Post()
@ApiOkResponse({ type: CreateUserRes })
async createUser(@User() user, @Body() body: CreateUserReq) {
async createUser(@User() user: RequestUser, @Body() body: CreateUserReq) {
this.logger.info('createUser', { user });
}
@Post('batch')
@ApiOkResponse({ type: CreateUserRes })
async batchCreateUser(@User() user, @Body() body: CreateUserReq) {
async batchCreateUser(
@User() user: RequestUser,
@Body() body: CreateUserReq,
) {
this.logger.info('batchCreateUser', { user });
}
@Delete(':id')
@ApiOkResponse({ type: DeleteUserRes })
async deleteUser(@User() user, @Param('id') id: string) {
async deleteUser(@User() user: RequestUser, @Param('id') id: string) {
this.logger.info('deleteUser', { user });
return await this.userService.deleteUser({ id });
}
@Put('role')
async assignRoleToUser(@User() user, @Body() body: AssignRoleToUserReq) {
async assignRoleToUser(
@User() user: RequestUser,
@Body() body: AssignRoleToUserReq,
) {
this.logger.info('assignRoleToUser', { user });
return await this.userService.assignRoleToUser(body);
}
@Delete('role')
async unassignRoleToUser(@User() user, @Body() body: UnassignRoleToUserReq) {
async unassignRoleToUser(
@User() user: RequestUser,
@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);
// }
}