carrer programa endpoints restringidos a usuario
This commit is contained in:
@@ -1,10 +1,12 @@
|
||||
import {
|
||||
Body,
|
||||
ConflictException,
|
||||
Controller,
|
||||
Delete,
|
||||
Get,
|
||||
Post,
|
||||
Query,
|
||||
Request,
|
||||
UseGuards,
|
||||
} from '@nestjs/common';
|
||||
import { AuthGuard } from '@nestjs/passport';
|
||||
@@ -17,6 +19,7 @@ import {
|
||||
} from '@nestjs/swagger';
|
||||
import { Serealize } from '../interceptors/serialize.interceptor';
|
||||
import { CarreraProgramaService } from './carrera-programa.service';
|
||||
import { Operador } from 'src/operador/entity/operador.entity';
|
||||
import { IdInstitucionDto } from '../dto/id-institucion.dto';
|
||||
import { CreateCarreraProgramaDto } from './dto/input/create.dto';
|
||||
import { DeleteCarreraProgramaDto } from './dto/input/delete.dto';
|
||||
@@ -40,8 +43,13 @@ export class CarreraProgramaController {
|
||||
ejemplo: { value: { id_institucion_carrera: 36, id_programa: 1 } },
|
||||
},
|
||||
})
|
||||
create(@Body() body: CreateCarreraProgramaDto) {
|
||||
create(@Request() req, @Body() body: CreateCarreraProgramaDto) {
|
||||
const admin: Operador = req.user.operador;
|
||||
|
||||
if (admin.tipoUsuario.id_tipo_usuario != 3)
|
||||
throw new ConflictException('No tienes permiso de realizar esta acción.');
|
||||
return this.carreraProgramaService.create(
|
||||
admin,
|
||||
body.id_institucion_carrera,
|
||||
body.id_programa,
|
||||
);
|
||||
@@ -58,8 +66,12 @@ export class CarreraProgramaController {
|
||||
description: 'Es obligatorio mandar la variable id_carrera_programa.',
|
||||
examples: { ejemplo: { value: { id_carrera_programa: 1 } } },
|
||||
})
|
||||
delete(@Body() body: DeleteCarreraProgramaDto) {
|
||||
return this.carreraProgramaService.delete(body.id_carrera_programa);
|
||||
delete(@Request() req, @Body() body: DeleteCarreraProgramaDto) {
|
||||
const admin: Operador = req.user.operador;
|
||||
|
||||
if (admin.tipoUsuario.id_tipo_usuario != 3)
|
||||
throw new ConflictException('No tienes permiso de realizar esta acción.');
|
||||
return this.carreraProgramaService.delete(admin, body.id_carrera_programa);
|
||||
}
|
||||
|
||||
@Serealize(CarreraProgramaOutputDto)
|
||||
|
||||
Reference in New Issue
Block a user