2022-08-06 14:40:22 -05:00
|
|
|
import {
|
|
|
|
|
Controller,
|
|
|
|
|
ForbiddenException,
|
|
|
|
|
Get,
|
|
|
|
|
Request,
|
|
|
|
|
UseGuards,
|
|
|
|
|
} from '@nestjs/common';
|
2022-06-23 23:07:12 -05:00
|
|
|
import { AuthGuard } from '@nestjs/passport';
|
2022-07-15 00:27:30 -05:00
|
|
|
import { ApiBearerAuth, ApiOperation, ApiTags } from '@nestjs/swagger';
|
2022-06-14 00:14:20 -05:00
|
|
|
import { Serealize } from '../interceptors/serialize.interceptor';
|
2022-05-30 15:27:43 -05:00
|
|
|
import { StatusService } from './status.service';
|
2022-06-14 00:14:20 -05:00
|
|
|
import { StatusOutputDto } from './dto/output/status.dto';
|
2022-08-06 14:40:22 -05:00
|
|
|
import { Operador } from 'src/operador/entity/operador.entity';
|
2022-03-29 22:03:19 -06:00
|
|
|
|
|
|
|
|
@Controller('status')
|
2022-04-30 21:18:19 -05:00
|
|
|
@ApiTags('status')
|
2022-04-04 20:53:32 -05:00
|
|
|
export class StatusController {
|
|
|
|
|
constructor(private statusService: StatusService) {}
|
2022-04-17 23:08:26 -05:00
|
|
|
|
2022-06-14 00:14:20 -05:00
|
|
|
@Serealize(StatusOutputDto)
|
2022-04-17 23:08:26 -05:00
|
|
|
@Get()
|
2022-07-15 00:27:30 -05:00
|
|
|
@UseGuards(AuthGuard('jwt'))
|
2022-05-30 15:26:54 -05:00
|
|
|
@ApiOperation({ description: 'Endpoint que retorna todos los status.' })
|
2022-07-15 00:27:30 -05:00
|
|
|
@ApiBearerAuth('jwt')
|
2022-08-06 14:40:22 -05:00
|
|
|
get(@Request() req) {
|
|
|
|
|
const operador: Operador = req.user.operador;
|
|
|
|
|
|
|
|
|
|
if (
|
|
|
|
|
!operador ||
|
|
|
|
|
(operador.tipoUsuario.id_tipo_usuario != 2 &&
|
|
|
|
|
operador.tipoUsuario.id_tipo_usuario != 3 &&
|
|
|
|
|
operador.tipoUsuario.id_tipo_usuario != 4)
|
|
|
|
|
)
|
|
|
|
|
throw new ForbiddenException(
|
|
|
|
|
'No tienes los permisos necesarios para acceder a esta información.',
|
|
|
|
|
);
|
2022-04-19 23:52:04 -05:00
|
|
|
return this.statusService.findAll();
|
|
|
|
|
}
|
2022-04-04 20:53:32 -05:00
|
|
|
}
|