modulo tipo usuario final
This commit is contained in:
@@ -68,7 +68,9 @@ export class InstitucionInfraccionService {
|
||||
.findOne({ id_institucion_infraccion })
|
||||
.then((institucionInfraccion) => {
|
||||
if (!institucionInfraccion)
|
||||
throw new NotFoundException('No existe esta institucion infracción.');
|
||||
throw new NotFoundException(
|
||||
'No existe este id institución infracción.',
|
||||
);
|
||||
return institucionInfraccion;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ export class InstitucionTipoEntradaService {
|
||||
.then((institucionTipoEntrada) => {
|
||||
if (!institucionTipoEntrada)
|
||||
throw new NotFoundException(
|
||||
'No existe esta institucion tipo entrada.',
|
||||
'No existe este id institución tipo entrada.',
|
||||
);
|
||||
return institucionTipoEntrada;
|
||||
});
|
||||
@@ -87,7 +87,7 @@ export class InstitucionTipoEntradaService {
|
||||
.findOne({ id_tipo_entrada })
|
||||
.then((tipoEntrada) => {
|
||||
if (!tipoEntrada)
|
||||
throw new NotFoundException('No existe este tipo de entrada.');
|
||||
throw new NotFoundException('No existe este id tipo de entrada.');
|
||||
return tipoEntrada;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ export class ModuloService {
|
||||
|
||||
findById(id_modulo: number) {
|
||||
return this.repository.findOne({ id_modulo }).then((modulo) => {
|
||||
if (!modulo) throw new NotFoundException('No existe este módulo.');
|
||||
if (!modulo) throw new NotFoundException('No existe este id módulo.');
|
||||
return modulo;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -116,7 +116,7 @@ export class OperadorService {
|
||||
|
||||
findById(id_operador: number) {
|
||||
return this.repository.findOne({ id_operador }).then((operador) => {
|
||||
if (!operador) throw new NotFoundException('No existe este operador.');
|
||||
if (!operador) throw new NotFoundException('No existe este id operador.');
|
||||
return operador;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -11,6 +11,17 @@ import { TipoUsuarioOutputDto } from './dto/output/tipo-usuario.dto';
|
||||
export class TipoUsuarioController {
|
||||
constructor(private tipoUsuarioService: TipoUsuarioService) {}
|
||||
|
||||
@Serealize(TipoUsuarioOutputDto)
|
||||
@Get('admin')
|
||||
// @UseGuards(AuthGuard('jwt'))
|
||||
@ApiOperation({
|
||||
description:
|
||||
'Endpoint que retorna todos los tipos de usuario que debe ver un admin.',
|
||||
})
|
||||
admin() {
|
||||
return this.tipoUsuarioService.findAll('admin');
|
||||
}
|
||||
|
||||
@Post()
|
||||
// @UseGuards(AuthGuard('jwt'))
|
||||
@ApiOperation({ description: 'Endpoint que crea un nuevo tipo de usuario.' })
|
||||
@@ -31,4 +42,26 @@ export class TipoUsuarioController {
|
||||
get() {
|
||||
return this.tipoUsuarioService.findAll();
|
||||
}
|
||||
|
||||
@Serealize(TipoUsuarioOutputDto)
|
||||
@Get('operador')
|
||||
// @UseGuards(AuthGuard('jwt'))
|
||||
@ApiOperation({
|
||||
description:
|
||||
'Endpoint que retorna todos los tipos de usuario que debe ver un operador.',
|
||||
})
|
||||
operador() {
|
||||
return this.tipoUsuarioService.findAll('operador');
|
||||
}
|
||||
|
||||
@Serealize(TipoUsuarioOutputDto)
|
||||
@Get('super-admin')
|
||||
// @UseGuards(AuthGuard('jwt'))
|
||||
@ApiOperation({
|
||||
description:
|
||||
'Endpoint que retorna todos los tipos de usuario que debe ver un super admin.',
|
||||
})
|
||||
superAdmin() {
|
||||
return this.tipoUsuarioService.findAll('super admin');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,14 +26,23 @@ export class TipoUsuarioService {
|
||||
}));
|
||||
}
|
||||
|
||||
findAll() {
|
||||
return this.repository.find();
|
||||
findAll(informacion?: string) {
|
||||
const query = this.repository
|
||||
.createQueryBuilder('tu')
|
||||
.where('tu.id_tipo_usuario != 1 AND tu.id_tipo_usuario != 2')
|
||||
.orderBy('tu.tipo_usuario');
|
||||
|
||||
if (informacion === 'super admin' || informacion === 'admin')
|
||||
query.andWhere('tu.id_tipo_usuario < 5');
|
||||
if (informacion === 'admin') query.andWhere('tu.id_tipo_usuario != 3');
|
||||
if (informacion === 'operador') query.andWhere('tu.id_tipo_usuario > 4');
|
||||
return query.getMany();
|
||||
}
|
||||
|
||||
findById(id_tipo_usuario: number) {
|
||||
return this.repository.findOne({ id_tipo_usuario }).then((tipoUsuario) => {
|
||||
if (!tipoUsuario)
|
||||
throw new NotFoundException('No existe este tipo usuario');
|
||||
throw new NotFoundException('No existe este id tipo usuario.');
|
||||
return tipoUsuario;
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user