Roles
This commit is contained in:
@@ -1,12 +1,17 @@
|
||||
import { Body, Controller, Delete, Get, Param, ParseIntPipe, Post, Put, Query } from '@nestjs/common';
|
||||
import { Body, Controller, Delete, Get, Param, ParseIntPipe, Post, Put, Query,UseGuards } from '@nestjs/common';
|
||||
import { ProfesorService } from './profesor.service';
|
||||
import { profesorDto } from './dto/profesorDto.dto';
|
||||
import {Roles} from '../permissions/roles.decorator'
|
||||
import {RolesGuard} from '../permissions/roles.guard'
|
||||
import {Role} from '../permissions/role.enum'
|
||||
|
||||
@Controller('profesor')
|
||||
@UseGuards(RolesGuard)
|
||||
export class ProfesorController {
|
||||
constructor(private profesorService: ProfesorService) {}
|
||||
|
||||
@Post()
|
||||
@Roles(Role.Responsable,Role.Admin)
|
||||
async register(@Body() data: profesorDto) {
|
||||
return this.profesorService.register(data);
|
||||
}
|
||||
@@ -25,11 +30,13 @@ export class ProfesorController {
|
||||
}
|
||||
|
||||
@Put(':id_profesor')
|
||||
@Roles(Role.Responsable,Role.Admin)
|
||||
async postModify(@Param('id_profesor', ParseIntPipe) id_profesor: number, @Body() data: profesorDto) {
|
||||
return this.profesorService.modify(id_profesor, data);
|
||||
}
|
||||
|
||||
@Delete(':id_profesor')
|
||||
@Roles(Role.Responsable,Role.Admin)
|
||||
async remove(@Param('id_profesor', ParseIntPipe) id_profesor: number) {
|
||||
return this.profesorService.remove(id_profesor);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user