marca y modelo endpoints restringidos a usuario
This commit is contained in:
@@ -47,7 +47,9 @@ export class CarreraProgramaController {
|
||||
const admin: Operador = req.user.operador;
|
||||
|
||||
if (!admin || admin.tipoUsuario.id_tipo_usuario != 3)
|
||||
throw new ConflictException('No tienes permiso de realizar esta acción.');
|
||||
throw new ConflictException(
|
||||
'No tienes permisos para realizar esta acción.',
|
||||
);
|
||||
return this.carreraProgramaService.create(
|
||||
admin,
|
||||
body.id_institucion_carrera,
|
||||
@@ -70,7 +72,9 @@ export class CarreraProgramaController {
|
||||
const admin: Operador = req.user.operador;
|
||||
|
||||
if (!admin || admin.tipoUsuario.id_tipo_usuario != 3)
|
||||
throw new ConflictException('No tienes permiso de realizar esta acción.');
|
||||
throw new ConflictException(
|
||||
'No tienes permisos para realizar esta acción.',
|
||||
);
|
||||
return this.carreraProgramaService.delete(admin, body.id_carrera_programa);
|
||||
}
|
||||
|
||||
|
||||
@@ -54,7 +54,9 @@ export class HoraExcepcionController {
|
||||
const admin: Operador = req.user.operador;
|
||||
|
||||
if (!admin || admin.tipoUsuario.id_tipo_usuario != 3)
|
||||
throw new ConflictException('No tienes permiso de realizar esta acción.');
|
||||
throw new ConflictException(
|
||||
'No tienes permisos para realizar esta acción.',
|
||||
);
|
||||
return this.horaExcepcionService.create(
|
||||
admin,
|
||||
body.id_institucion_dia,
|
||||
@@ -77,7 +79,9 @@ export class HoraExcepcionController {
|
||||
const admin: Operador = req.user.operador;
|
||||
|
||||
if (!admin || admin.tipoUsuario.id_tipo_usuario != 3)
|
||||
throw new ConflictException('No tienes permiso de realizar esta acción.');
|
||||
throw new ConflictException(
|
||||
'No tienes permisos para realizar esta acción.',
|
||||
);
|
||||
return this.horaExcepcionService.delete(admin, body.id_hora_excepcion);
|
||||
}
|
||||
|
||||
@@ -119,7 +123,9 @@ export class HoraExcepcionController {
|
||||
const admin: Operador = req.user.operador;
|
||||
|
||||
if (!admin || admin.tipoUsuario.id_tipo_usuario != 3)
|
||||
throw new ConflictException('No tienes permiso de realizar esta acción.');
|
||||
throw new ConflictException(
|
||||
'No tienes permisos para realizar esta acción.',
|
||||
);
|
||||
return this.horaExcepcionService.update(admin, body);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,7 +88,9 @@ export class InstitucionDiaController {
|
||||
const admin: Operador = req.user.operador;
|
||||
|
||||
if (!admin || admin.tipoUsuario.id_tipo_usuario != 3)
|
||||
throw new ConflictException('No tienes permiso de realizar esta acción.');
|
||||
throw new ConflictException(
|
||||
'No tienes permisos para realizar esta acción.',
|
||||
);
|
||||
return this.institucionDiaService.update(admin, body);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,7 +45,9 @@ export class InstitucionInfraccionController {
|
||||
const superAdmin: Operador = req.user.operador;
|
||||
|
||||
if (!superAdmin || superAdmin.tipoUsuario.id_tipo_usuario != 2)
|
||||
throw new ConflictException('No tienes permiso de realizar esta acción.');
|
||||
throw new ConflictException(
|
||||
'No tienes permisos para realizar esta acción.',
|
||||
);
|
||||
return this.institucionInfraccionService.create(body.infraccion);
|
||||
}
|
||||
|
||||
@@ -92,7 +94,9 @@ export class InstitucionInfraccionController {
|
||||
const admin: Operador = req.user.operador;
|
||||
|
||||
if (!admin || admin.tipoUsuario.id_tipo_usuario != 3)
|
||||
throw new ConflictException('No tienes permiso de realizar esta acción.');
|
||||
throw new ConflictException(
|
||||
'No tienes permisos para realizar esta acción.',
|
||||
);
|
||||
return this.institucionInfraccionService.update(admin, body);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,7 +44,9 @@ export class InstitucionProgramaController {
|
||||
const superAdmin: Operador = req.user.operador;
|
||||
|
||||
if (!superAdmin || superAdmin.tipoUsuario.id_tipo_usuario != 2)
|
||||
throw new ConflictException('No tienes permiso de realizar esta acción.');
|
||||
throw new ConflictException(
|
||||
'No tienes permisos para realizar esta acción.',
|
||||
);
|
||||
return this.institucionProgramaService.create(body.programa);
|
||||
}
|
||||
|
||||
@@ -112,7 +114,9 @@ export class InstitucionProgramaController {
|
||||
const admin: Operador = req.user.operador;
|
||||
|
||||
if (!admin || admin.tipoUsuario.id_tipo_usuario != 3)
|
||||
throw new ConflictException('No tienes permiso de realizar esta acción.');
|
||||
throw new ConflictException(
|
||||
'No tienes permisos para realizar esta acción.',
|
||||
);
|
||||
return this.institucionProgramaService.update(admin, body);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,7 +46,9 @@ export class InstitucionTipoCarritoController {
|
||||
const superAdmin: Operador = req.user.operador;
|
||||
|
||||
if (!superAdmin || superAdmin.tipoUsuario.id_tipo_usuario != 2)
|
||||
throw new ConflictException('No tienes permiso de realizar esta acción.');
|
||||
throw new ConflictException(
|
||||
'No tienes permisos para realizar esta acción.',
|
||||
);
|
||||
return this.institucionTipoCarritoService.create(
|
||||
body.letra,
|
||||
body.tipo_carrito,
|
||||
@@ -120,7 +122,9 @@ export class InstitucionTipoCarritoController {
|
||||
const admin: Operador = req.user.operador;
|
||||
|
||||
if (!admin || admin.tipoUsuario.id_tipo_usuario != 3)
|
||||
throw new ConflictException('No tienes permiso de realizar esta acción.');
|
||||
throw new ConflictException(
|
||||
'No tienes permisos para realizar esta acción.',
|
||||
);
|
||||
return this.institucionTipoCarritoService.update(admin, body);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,7 +44,9 @@ export class InstitucionTipoEntradaController {
|
||||
const superAdmin: Operador = req.user.operador;
|
||||
|
||||
if (!superAdmin || superAdmin.tipoUsuario.id_tipo_usuario != 2)
|
||||
throw new ConflictException('No tienes permiso de realizar esta acción.');
|
||||
throw new ConflictException(
|
||||
'No tienes permisos para realizar esta acción.',
|
||||
);
|
||||
return this.tipoEntradaService.create(body.tipo_entrada);
|
||||
}
|
||||
|
||||
@@ -115,7 +117,9 @@ export class InstitucionTipoEntradaController {
|
||||
const admin: Operador = req.user.operador;
|
||||
|
||||
if (!admin || admin.tipoUsuario.id_tipo_usuario != 3)
|
||||
throw new ConflictException('No tienes permiso de realizar esta acción.');
|
||||
throw new ConflictException(
|
||||
'No tienes permisos para realizar esta acción.',
|
||||
);
|
||||
return this.tipoEntradaService.update(admin, body);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -123,7 +123,9 @@ export class InstitucionController {
|
||||
(admin.tipoUsuario.id_tipo_usuario != 2 &&
|
||||
admin.tipoUsuario.id_tipo_usuario != 3)
|
||||
)
|
||||
throw new ConflictException('No tienes permiso de realizar esta acción.');
|
||||
throw new ConflictException(
|
||||
'No tienes permisos para realizar esta acción.',
|
||||
);
|
||||
return this.institucionService.update(admin, body);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,13 @@
|
||||
import { Body, Controller, Get, Post, Query, UseGuards } from '@nestjs/common';
|
||||
import {
|
||||
Body,
|
||||
ConflictException,
|
||||
Controller,
|
||||
Get,
|
||||
Post,
|
||||
Query,
|
||||
Request,
|
||||
UseGuards,
|
||||
} from '@nestjs/common';
|
||||
import { AuthGuard } from '@nestjs/passport';
|
||||
import {
|
||||
ApiBearerAuth,
|
||||
@@ -9,6 +18,7 @@ import {
|
||||
} from '@nestjs/swagger';
|
||||
import { Serealize } from '../interceptors/serialize.interceptor';
|
||||
import { MarcaService } from './marca.service';
|
||||
import { Operador } from 'src/operador/entity/operador.entity';
|
||||
import { CreateMarcaDto } from './dto/input/create.dto';
|
||||
import { MarcaDto } from './dto/input/marca.dto';
|
||||
import { MarcaOutputDto } from './dto/output/marca.dto';
|
||||
@@ -40,7 +50,13 @@ export class MarcaController {
|
||||
description: 'Todas las variables son obligatorias.',
|
||||
examples: { ejemplo: { value: { marca: '', tipo: '' } } },
|
||||
})
|
||||
create(@Body() body: CreateMarcaDto) {
|
||||
create(@Request() req, @Body() body: CreateMarcaDto) {
|
||||
const superAdmin: Operador = req.user.operador;
|
||||
|
||||
if (!superAdmin || superAdmin.tipoUsuario.id_tipo_usuario != 2)
|
||||
throw new ConflictException(
|
||||
'No tienes permisos para realizar esta acción.',
|
||||
);
|
||||
return this.marcaService.create(body.marca, body.tipo);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,13 @@
|
||||
import { Body, Controller, Get, Post, Query, UseGuards } from '@nestjs/common';
|
||||
import {
|
||||
Body,
|
||||
ConflictException,
|
||||
Controller,
|
||||
Get,
|
||||
Post,
|
||||
Query,
|
||||
Request,
|
||||
UseGuards,
|
||||
} from '@nestjs/common';
|
||||
import { AuthGuard } from '@nestjs/passport';
|
||||
import {
|
||||
ApiBearerAuth,
|
||||
@@ -9,6 +18,7 @@ import {
|
||||
} from '@nestjs/swagger';
|
||||
import { Serealize } from '../interceptors/serialize.interceptor';
|
||||
import { ModeloService } from './modelo.service';
|
||||
import { Operador } from 'src/operador/entity/operador.entity';
|
||||
import { CreateModeloDto } from './dto/input/create.dto';
|
||||
import { ModeloDto } from './dto/input/modelo.dto';
|
||||
import { ModeloOutputDto } from './dto/output/modelo.dto';
|
||||
@@ -40,7 +50,13 @@ export class ModeloController {
|
||||
description: 'Todas las variables son obligatorias.',
|
||||
examples: { ejemplo: { value: { modelo: '', tipo: '' } } },
|
||||
})
|
||||
create(@Body() body: CreateModeloDto) {
|
||||
create(@Request() req, @Body() body: CreateModeloDto) {
|
||||
const superAdmin: Operador = req.user.operador;
|
||||
|
||||
if (!superAdmin || superAdmin.tipoUsuario.id_tipo_usuario != 2)
|
||||
throw new ConflictException(
|
||||
'No tienes permisos para realizar esta acción.',
|
||||
);
|
||||
return this.modeloService.create(body.modelo, body.tipo);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user