added all roles

This commit is contained in:
2026-03-02 14:49:15 -06:00
parent 8aa0eab353
commit 0323c93ca3
22 changed files with 233 additions and 92 deletions
+12 -5
View File
@@ -2,33 +2,40 @@ import { Body, Controller, Post, Req, UseGuards } from '@nestjs/common';
import { OperationsService } from './operations.services';
import { chargePrintDto } from './dto/operations.dto';
import { JwtAuthGuard } from 'src/user/jwt.guard';
import { RolesGuard } from 'src/roles.guard';
import { Roles } from 'src/roles.decorator';
import { Role } from 'src/role.enum';
@Controller('operations')
export class OperationsController {
constructor(private readonly operationsService: OperationsService) {}
constructor(private readonly operationsService: OperationsService) { }
@UseGuards(JwtAuthGuard)
@UseGuards(JwtAuthGuard, RolesGuard)
@Roles(Role.ADMINISTRADOR, Role.SUPER_ADMINISTRADOR, Role.ATENCION_USUARIOS, Role.PCPUMA, Role.SERVICIO_SOCIAL)
@Post('impressions')
async chargePrint(@Body() data: chargePrintDto, @Req() req: any) {
const id_usuario = req.user.id;
return this.operationsService.chargePrint(data, id_usuario);
}
@UseGuards(JwtAuthGuard)
@UseGuards(JwtAuthGuard, RolesGuard)
@Roles(Role.ADMINISTRADOR, Role.SUPER_ADMINISTRADOR, Role.ATENCION_USUARIOS, Role.PCPUMA, Role.SERVICIO_SOCIAL)
@Post('receipt')
async addCredit(@Body() data, @Req() req: any) {
const id_usuario = req.user.id;
return this.operationsService.addCredit(data, id_usuario);
}
@UseGuards(JwtAuthGuard)
@UseGuards(JwtAuthGuard, RolesGuard)
@Roles(Role.ADMINISTRADOR, Role.SUPER_ADMINISTRADOR, Role.SERVICIO_SOCIAL, Role.ATENCION_USUARIOS)
@Post('registration')
async addReceiptInscription(@Body() data, @Req() req: any) {
const id_usuario = req.user.id;
return this.operationsService.addReceiptInscription(data, id_usuario);
}
@UseGuards(JwtAuthGuard)
@UseGuards(JwtAuthGuard, RolesGuard)
@Roles(Role.ADMINISTRADOR, Role.SUPER_ADMINISTRADOR, Role.SERVICIO_SOCIAL, Role.ATENCION_USUARIOS)
@Post('time')
async addTime(@Body() data, @Req() req: any) {
const id_usuario = req.user.id;
+10 -5
View File
@@ -11,31 +11,36 @@ import { Role } from 'src/role.enum';
export class AlumnoController {
constructor(private readonly alumnoService: AlumnoService) { }
@UseGuards(JwtAuthGuard)
@UseGuards(JwtAuthGuard, RolesGuard)
@Roles(Role.ADMINISTRADOR, Role.SUPER_ADMINISTRADOR)
@Get()
async find() {
return this.alumnoService.findAll()
}
@UseGuards(JwtAuthGuard)
@UseGuards(JwtAuthGuard, RolesGuard)
@Roles(Role.ADMINISTRADOR, Role.SUPER_ADMINISTRADOR)
@Post()
async create(@Body() createStudentDto: CreateStudentDto): Promise<Alumno> {
return this.alumnoService.create(createStudentDto);
}
@UseGuards(JwtAuthGuard)
@UseGuards(JwtAuthGuard, RolesGuard)
@Roles(Role.ADMINISTRADOR, Role.SUPER_ADMINISTRADOR,Role.ATENCION_USUARIOS,Role.SERVICIO_SOCIAL,Role.PCPUMA)
@Get(':id')
findOneWhitSancion(@Param('id') id: number) {
return this.alumnoService.findOneWhitSancion(+id);
}
@UseGuards(JwtAuthGuard)
@UseGuards(JwtAuthGuard, RolesGuard)
@Roles(Role.ADMINISTRADOR, Role.SUPER_ADMINISTRADOR,Role.ATENCION_USUARIOS,Role.SERVICIO_SOCIAL,Role.PCPUMA)
@Get('sancion/:id')
findOne(@Param('id') id: number) {
return this.alumnoService.findOne(+id);
}
@UseGuards(JwtAuthGuard)
@UseGuards(JwtAuthGuard, RolesGuard)
@Roles(Role.ADMINISTRADOR, Role.SUPER_ADMINISTRADOR)
@Post('/create')
async newStudent(@Body() createStudentDto: CreateStudentDto) {
return this.alumnoService.create(createStudentDto);
@@ -5,36 +5,44 @@ import {
} from './dto/create-alumno_inscrito.dto';
import { AlumnoInscrito } from './entities/alumno_inscrito.entity';
import { JwtAuthGuard } from 'src/user/jwt.guard';
import { RolesGuard } from 'src/roles.guard';
import { Roles } from 'src/roles.decorator';
import { Role } from 'src/role.enum';
@Controller('alumno-inscrito')
export class AlumnoInscritoController {
constructor(private readonly alumnoInscritoService: AlumnoInscritoService) { }
@UseGuards(JwtAuthGuard)
@UseGuards(JwtAuthGuard, RolesGuard)
@Roles(Role.ADMINISTRADOR, Role.SUPER_ADMINISTRADOR,Role.ATENCION_USUARIOS,Role.SERVICIO_SOCIAL)
@Post()
async create(@Body() dto: CreateAlumnoInscritoDto): Promise<AlumnoInscrito> {
return this.alumnoInscritoService.createWhitoutPay(dto);
}
@UseGuards(JwtAuthGuard)
@UseGuards(JwtAuthGuard, RolesGuard)
@Roles(Role.ADMINISTRADOR, Role.SUPER_ADMINISTRADOR)
@Get()
async findAll(): Promise<AlumnoInscrito[]> {
return this.alumnoInscritoService.findAll();
}
@UseGuards(JwtAuthGuard)
@UseGuards(JwtAuthGuard, RolesGuard)
@Roles(Role.ADMINISTRADOR, Role.SUPER_ADMINISTRADOR)
@Get("/inscritos/:idPeriodo")
async findAllInscritos(@Param('idPeriodo') idPeriodo: number) {
return this.alumnoInscritoService.findAllInscritos(idPeriodo);
}
@UseGuards(JwtAuthGuard)
@UseGuards(JwtAuthGuard, RolesGuard)
@Roles(Role.ADMINISTRADOR, Role.SUPER_ADMINISTRADOR)
@Get('/plataforma')
async findAllPlataforma() {
return this.alumnoInscritoService.findAllPlataforma();
}
@UseGuards(JwtAuthGuard)
@UseGuards(JwtAuthGuard, RolesGuard)
@Roles(Role.ADMINISTRADOR, Role.SUPER_ADMINISTRADOR,Role.ATENCION_USUARIOS,Role.SERVICIO_SOCIAL)
@Get(':id_cuenta')
async findByIdWhitoud(
@Param('id_cuenta') id_cuenta: number,
@@ -42,7 +50,8 @@ export class AlumnoInscritoController {
return this.alumnoInscritoService.findByIdWhitoud(id_cuenta);
}
@UseGuards(JwtAuthGuard)
@UseGuards(JwtAuthGuard, RolesGuard)
@Roles(Role.ADMINISTRADOR, Role.SUPER_ADMINISTRADOR,Role.ATENCION_USUARIOS,Role.SERVICIO_SOCIAL)
@Get(':id_cuenta/sancion')
async findById(
@Param('id_cuenta') id_cuenta: number,
@@ -2,24 +2,30 @@ import { Body, Controller, Delete, Get, Param, Post, UseGuards } from '@nestjs/c
import { AlumnoSancionService } from './alumno_sancion.service';
import { CreateAlumnoSancionDto } from './dto/create-alumno_sancion.dto';
import { JwtAuthGuard } from 'src/user/jwt.guard';
import { RolesGuard } from 'src/roles.guard';
import { Roles } from 'src/roles.decorator';
import { Role } from 'src/role.enum';
@Controller('alumno-sancion')
export class AlumnoSancionController {
constructor(private readonly alumnoSancionService: AlumnoSancionService) { }
@UseGuards(JwtAuthGuard)
@UseGuards(JwtAuthGuard, RolesGuard)
@Roles(Role.ADMINISTRADOR, Role.SUPER_ADMINISTRADOR)
@Post()
async create(@Body() createAlumnoSancionDto: CreateAlumnoSancionDto) {
return this.alumnoSancionService.create(createAlumnoSancionDto);
}
@UseGuards(JwtAuthGuard)
@UseGuards(JwtAuthGuard, RolesGuard)
@Roles(Role.ADMINISTRADOR, Role.SUPER_ADMINISTRADOR)
@Get(':id')
findbyStudent(@Param('id') id: number) {
return this.alumnoSancionService.findbyStudent(+id);
}
@UseGuards(JwtAuthGuard)
@UseGuards(JwtAuthGuard, RolesGuard)
@Roles(Role.ADMINISTRADOR, Role.SUPER_ADMINISTRADOR)
@Delete(':id_cuenta')
async deleteSancionesAlumno(@Param('id_cuenta') id_cuenta: number) {
return this.alumnoSancionService.removeByStudent(+id_cuenta);
@@ -1,24 +1,30 @@
import { Controller, Get, Param, UseGuards } from '@nestjs/common';
import { AreaUbicacionService } from './area_ubicacion.service';
import { JwtAuthGuard } from 'src/user/jwt.guard';
import { RolesGuard } from 'src/roles.guard';
import { Roles } from 'src/roles.decorator';
import { Role } from 'src/role.enum';
@Controller('area-ubicacion')
export class AreaUbicacionController {
constructor(private readonly areaUbicacionService: AreaUbicacionService) { }
@UseGuards(JwtAuthGuard)
@Get()
@UseGuards(JwtAuthGuard, RolesGuard)
@Roles(Role.ADMINISTRADOR, Role.SUPER_ADMINISTRADOR,Role.ATENCION_USUARIOS,Role.SERVICIO_SOCIAL)
@Get()
findAll() {
return this.areaUbicacionService.findAll();
}
@UseGuards(JwtAuthGuard)
@UseGuards(JwtAuthGuard, RolesGuard)
@Roles(Role.ADMINISTRADOR, Role.SUPER_ADMINISTRADOR)
@Get(':id')
findOne(@Param('id') id: string) {
return this.areaUbicacionService.findOne(+id);
}
@UseGuards(JwtAuthGuard)
@UseGuards(JwtAuthGuard, RolesGuard)
@Roles(Role.ADMINISTRADOR, Role.SUPER_ADMINISTRADOR)
@Get('/programs/:id')
findProgramsByArea(@Param('id') id: number) {
return this.areaUbicacionService.findProgramsByArea(+id)
+17 -7
View File
@@ -2,30 +2,37 @@ import { Controller, Get, Post, Body, Param, Patch, UseGuards } from '@nestjs/co
import { BitacoraService } from './bitacora.service';
import { BitacoraAlumnoDto, CreateBitacoraDto, EquiposPorEquipoDto } from './dto/create-bitacora.dto';
import { JwtAuthGuard } from 'src/user/jwt.guard';
import { RolesGuard } from 'src/roles.guard';
import { Roles } from 'src/roles.decorator';
import { Role } from 'src/role.enum';
@Controller('bitacora')
export class BitacoraController {
constructor(private readonly bitacoraService: BitacoraService) { }
@UseGuards(JwtAuthGuard)
@UseGuards(JwtAuthGuard, RolesGuard)
@Roles(Role.ADMINISTRADOR, Role.SUPER_ADMINISTRADOR,Role.ATENCION_USUARIOS,Role.SERVICIO_SOCIAL)
@Post()
assignment(@Body() createBitacoraDto: CreateBitacoraDto) {
return this.bitacoraService.assignment(createBitacoraDto);
}
@UseGuards(JwtAuthGuard)
@UseGuards(JwtAuthGuard, RolesGuard)
@Roles(Role.ADMINISTRADOR, Role.SUPER_ADMINISTRADOR,Role.ATENCION_USUARIOS,Role.SERVICIO_SOCIAL)
@Get('/cuenta/:id')
findOneByAcount(@Param('id') id: string) {
return this.bitacoraService.findOneByAcount(+id);
}
@UseGuards(JwtAuthGuard)
@UseGuards(JwtAuthGuard, RolesGuard)
@Roles(Role.ADMINISTRADOR, Role.SUPER_ADMINISTRADOR,Role.ATENCION_USUARIOS,Role.SERVICIO_SOCIAL)
@Get('/equipo/:id')
findOneByMachine(@Param('id') id: string) {
return this.bitacoraService.findOneByMachine(+id);
}
@UseGuards(JwtAuthGuard)
@UseGuards(JwtAuthGuard, RolesGuard)
@Roles(Role.ADMINISTRADOR, Role.SUPER_ADMINISTRADOR,Role.ATENCION_USUARIOS,Role.SERVICIO_SOCIAL)
@Patch('cancelar/:id')
cancelationByMachine(
@Param('id') id: number,
@@ -34,13 +41,15 @@ export class BitacoraController {
return this.bitacoraService.cancelation(id, tiempo_asignado);
}
@UseGuards(JwtAuthGuard)
@UseGuards(JwtAuthGuard, RolesGuard)
@Roles(Role.ADMINISTRADOR, Role.SUPER_ADMINISTRADOR)
@Get()
findAll() {
return this.bitacoraService.findAll();
}
@UseGuards(JwtAuthGuard)
@UseGuards(JwtAuthGuard, RolesGuard)
@Roles(Role.ADMINISTRADOR, Role.SUPER_ADMINISTRADOR)
@Post('equipos-por-dia')
async obtenerEquipos(
@Body() dto: BitacoraAlumnoDto
@@ -51,7 +60,8 @@ export class BitacoraController {
);
}
@UseGuards(JwtAuthGuard)
@UseGuards(JwtAuthGuard, RolesGuard)
@Roles(Role.ADMINISTRADOR, Role.SUPER_ADMINISTRADOR)
@Post('equipos-por-equipo')
async equiposPorEquipo(
@Body() dto: EquiposPorEquipoDto,
+19 -8
View File
@@ -10,48 +10,58 @@ import {
import { BitacoraMesaService } from './bitacora_mesa.service';
import { CreateBitacoraMesaDto, FindByDate } from './dto/create-bitacora_mesa.dto';
import { JwtAuthGuard } from 'src/user/jwt.guard';
import { RolesGuard } from 'src/roles.guard';
import { Roles } from 'src/roles.decorator';
import { Role } from 'src/role.enum';
@Controller('bitacora-mesa')
export class BitacoraMesaController {
constructor(private readonly bitacoraMesaService: BitacoraMesaService) { }
@UseGuards(JwtAuthGuard)
@UseGuards(JwtAuthGuard, RolesGuard)
@Roles(Role.ADMINISTRADOR, Role.SUPER_ADMINISTRADOR,Role.ATENCION_USUARIOS,Role.SERVICIO_SOCIAL)
@Post()
assignment(@Body() createBitacoraMesaDto: CreateBitacoraMesaDto) {
return this.bitacoraMesaService.assignment(createBitacoraMesaDto);
}
@UseGuards(JwtAuthGuard)
@UseGuards(JwtAuthGuard, RolesGuard)
@Roles(Role.ADMINISTRADOR, Role.SUPER_ADMINISTRADOR)
@Get()
findAll() {
return this.bitacoraMesaService.findAll();
}
@UseGuards(JwtAuthGuard)
@UseGuards(JwtAuthGuard, RolesGuard)
@Roles(Role.ADMINISTRADOR, Role.SUPER_ADMINISTRADOR)
@Get(':id')
findOne(@Param('id') id: string) {
return this.bitacoraMesaService.findOne(+id);
}
@UseGuards(JwtAuthGuard)
@UseGuards(JwtAuthGuard, RolesGuard)
@Roles(Role.ADMINISTRADOR, Role.SUPER_ADMINISTRADOR,Role.ATENCION_USUARIOS,Role.SERVICIO_SOCIAL)
@Get('/cuenta/:id_cuenta')
findByCuenta(@Param('id_cuenta') id_cuenta: string) {
return this.bitacoraMesaService.findByCuenta(+id_cuenta);
}
@UseGuards(JwtAuthGuard)
@UseGuards(JwtAuthGuard, RolesGuard)
@Roles(Role.ADMINISTRADOR, Role.SUPER_ADMINISTRADOR,Role.ATENCION_USUARIOS,Role.SERVICIO_SOCIAL)
@Get('/table/:id_mesa')
findByTable(@Param('id_mesa') id_mesa: number) {
return this.bitacoraMesaService.findByTable(id_mesa);
}
@UseGuards(JwtAuthGuard)
@UseGuards(JwtAuthGuard, RolesGuard)
@Roles(Role.ADMINISTRADOR, Role.SUPER_ADMINISTRADOR)
@Post('/date')
findByDate(@Body() data: FindByDate) {
return this.bitacoraMesaService.findByDate(data.date);
}
@UseGuards(JwtAuthGuard)
@UseGuards(JwtAuthGuard, RolesGuard)
@Roles(Role.ADMINISTRADOR, Role.SUPER_ADMINISTRADOR,Role.ATENCION_USUARIOS,Role.SERVICIO_SOCIAL)
@Patch('cancelar/:id')
cancelationByMachine(
@Param('id') id: number,
@@ -60,7 +70,8 @@ export class BitacoraMesaController {
return this.bitacoraMesaService.cancelation(id, tiempo_asignado);
}
@UseGuards(JwtAuthGuard)
@UseGuards(JwtAuthGuard, RolesGuard)
@Roles(Role.ADMINISTRADOR, Role.SUPER_ADMINISTRADOR)
@Post('mesas-por-dia')
mesasPorDia(@Body() body: { fecha: string }) {
return this.bitacoraMesaService.mesasPorFecha(body.fecha);
+5 -1
View File
@@ -2,12 +2,16 @@ import { Controller, Get, UseGuards } from '@nestjs/common';
import { CarreraService } from './carrera.service';
import { Carrera } from './entities/carrera.entity';
import { JwtAuthGuard } from 'src/user/jwt.guard';
import { RolesGuard } from 'src/roles.guard';
import { Roles } from 'src/roles.decorator';
import { Role } from 'src/role.enum';
@Controller('carrera')
export class CarreraController {
constructor(private readonly carreraService: CarreraService) { }
@UseGuards(JwtAuthGuard)
@UseGuards(JwtAuthGuard, RolesGuard)
@Roles(Role.ADMINISTRADOR, Role.SUPER_ADMINISTRADOR,Role.ATENCION_USUARIOS,Role.SERVICIO_SOCIAL)
@Get()
findAll(): Promise<Carrera[]> {
return this.carreraService.findAll();
+7 -2
View File
@@ -1,18 +1,23 @@
import { Controller, Get, Param, UseGuards } from '@nestjs/common';
import { CostoService } from './costo.service';
import { JwtAuthGuard } from 'src/user/jwt.guard';
import { RolesGuard } from 'src/roles.guard';
import { Role } from 'src/role.enum';
import { Roles } from 'src/roles.decorator';
@Controller('costo')
export class CostoController {
constructor(private readonly costoService: CostoService) { }
@UseGuards(JwtAuthGuard)
@UseGuards(JwtAuthGuard, RolesGuard)
@Roles(Role.ADMINISTRADOR, Role.SUPER_ADMINISTRADOR,Role.ATENCION_USUARIOS,Role.SERVICIO_SOCIAL,Role.PCPUMA)
@Get()
findAll() {
return this.costoService.findAll();
}
@UseGuards(JwtAuthGuard)
@UseGuards(JwtAuthGuard, RolesGuard)
@Roles(Role.ADMINISTRADOR, Role.SUPER_ADMINISTRADOR)
@Get('/:id_servicio')
find(@Param('id_servicio') id_servicio: number) {
return this.costoService.find(id_servicio);
@@ -2,19 +2,24 @@ import { Body, Controller, Get, Post, UseGuards } from '@nestjs/common';
import { DetalleServicioService } from './detalle_servicio.service';
import { FindReciboByRangeDto } from 'src/recibo/dto/create-recibo.dto';
import { JwtAuthGuard } from 'src/user/jwt.guard';
import { RolesGuard } from 'src/roles.guard';
import { Roles } from 'src/roles.decorator';
import { Role } from 'src/role.enum';
@Controller('detalle-servicio')
export class DetalleServicioController {
constructor(private readonly detalleServicioService: DetalleServicioService) { }
@UseGuards(JwtAuthGuard)
@UseGuards(JwtAuthGuard, RolesGuard)
@Roles(Role.ADMINISTRADOR, Role.SUPER_ADMINISTRADOR)
@Get()
findAll() {
return this.detalleServicioService.findAll()
}
@UseGuards(JwtAuthGuard)
@UseGuards(JwtAuthGuard, RolesGuard)
@Roles(Role.ADMINISTRADOR, Role.SUPER_ADMINISTRADOR)
@Post('rango')
async findByDateRange(@Body() data: FindReciboByRangeDto) {
return this.detalleServicioService.findByDateRange(data.desde, data.hasta);
+23 -10
View File
@@ -3,66 +3,79 @@ import { EquipoService } from './equipo.service';
import { Equipo } from './entities/equipo.entity';
import { CreateEquipoDto, UpdateAreaEquiposDto } from './dto/create-equipo.dto';
import { JwtAuthGuard } from 'src/user/jwt.guard';
import { RolesGuard } from 'src/roles.guard';
import { Roles } from 'src/roles.decorator';
import { Role } from 'src/role.enum';
@Controller('equipo')
export class EquipoController {
constructor(private readonly equipoService: EquipoService) { }
@UseGuards(JwtAuthGuard)
@UseGuards(JwtAuthGuard, RolesGuard)
@Get()
@Roles(Role.ADMINISTRADOR, Role.SUPER_ADMINISTRADOR, Role.ATENCION_USUARIOS, Role.SERVICIO_SOCIAL)
findAll(): Promise<Equipo[]> {
return this.equipoService.findAll();
}
@UseGuards(JwtAuthGuard)
@UseGuards(JwtAuthGuard, RolesGuard)
@Roles(Role.ADMINISTRADOR, Role.SUPER_ADMINISTRADOR,Role.ATENCION_USUARIOS,Role.SERVICIO_SOCIAL)
@Get('/active')
findActive() {
return this.equipoService.findActive();
}
@UseGuards(JwtAuthGuard)
@UseGuards(JwtAuthGuard, RolesGuard)
@Roles(Role.ADMINISTRADOR, Role.SUPER_ADMINISTRADOR)
@Get('/disable')
findDisable() {
return this.equipoService.findDisable();
}
@UseGuards(JwtAuthGuard)
@UseGuards(JwtAuthGuard, RolesGuard)
@Roles(Role.ADMINISTRADOR, Role.SUPER_ADMINISTRADOR,Role.ATENCION_USUARIOS,Role.SERVICIO_SOCIAL)
@Get('/student/:id')
findOnlyUsable(@Param('id') id: number): Promise<Equipo[]> {
return this.equipoService.findOnlyUsable(+id);
}
@UseGuards(JwtAuthGuard)
@UseGuards(JwtAuthGuard, RolesGuard)
@Roles(Role.ADMINISTRADOR, Role.SUPER_ADMINISTRADOR)
@Get('/busy')
findOnlyBusy(): Promise<Equipo[]> {
return this.equipoService.findOnlyBusy();
}
@UseGuards(JwtAuthGuard)
@UseGuards(JwtAuthGuard, RolesGuard)
@Roles(Role.ADMINISTRADOR, Role.SUPER_ADMINISTRADOR)
@Get(':id')
findOne(@Param('id') id: string): Promise<Equipo> {
return this.equipoService.findOne(id);
}
@UseGuards(JwtAuthGuard)
@UseGuards(JwtAuthGuard, RolesGuard)
@Roles(Role.ADMINISTRADOR, Role.SUPER_ADMINISTRADOR)
@Post()
create(@Body() equipo: CreateEquipoDto) {
return this.equipoService.create(equipo);
}
@UseGuards(JwtAuthGuard)
@UseGuards(JwtAuthGuard, RolesGuard)
@Roles(Role.ADMINISTRADOR, Role.SUPER_ADMINISTRADOR)
@Patch()
update(@Body() equipo: CreateEquipoDto) {
return this.equipoService.update(equipo);
}
@UseGuards(JwtAuthGuard)
@UseGuards(JwtAuthGuard, RolesGuard)
@Roles(Role.ADMINISTRADOR, Role.SUPER_ADMINISTRADOR, Role.ATENCION_USUARIOS, Role.SERVICIO_SOCIAL)
@Patch(':id/activo')
toggleActivo(@Param('id') id: number) {
return this.equipoService.toggleActivo(+id);
}
@UseGuards(JwtAuthGuard)
@UseGuards(JwtAuthGuard, RolesGuard)
@Roles(Role.ADMINISTRADOR, Role.SUPER_ADMINISTRADOR,Role.ATENCION_USUARIOS,Role.SERVICIO_SOCIAL)
@Patch('actualizar-area')
actualizarPorArea(
@Body() updateAreaEquiposDto: UpdateAreaEquiposDto,
+7 -3
View File
@@ -1,18 +1,22 @@
import { Controller, Get, Param, UseGuards } from '@nestjs/common';
import { MensajeService } from './mensaje.service';
import { JwtAuthGuard } from 'src/user/jwt.guard';
import { RolesGuard } from 'src/roles.guard';
import { Roles } from 'src/roles.decorator';
import { Role } from 'src/role.enum';
@Controller('mensaje')
export class MensajeController {
constructor(private readonly mensajeService: MensajeService) { }
@UseGuards(JwtAuthGuard)
@Get()
@UseGuards(JwtAuthGuard, RolesGuard)
@Get() @Roles(Role.ADMINISTRADOR, Role.SUPER_ADMINISTRADOR)
findAll() {
return this.mensajeService.findAll();
}
@UseGuards(JwtAuthGuard)
@UseGuards(JwtAuthGuard, RolesGuard)
@Roles(Role.ADMINISTRADOR, Role.SUPER_ADMINISTRADOR)
@Get(':id')
findOne(@Param('id') id: string) {
return this.mensajeService.findOne(+id);
+13 -5
View File
@@ -2,30 +2,37 @@ import { Controller, Body, Patch, Param, Get, UseGuards } from '@nestjs/common';
import { MesaService } from './mesa.service';
import { UpdateMesaDto } from './dto/update-mesa.dto';
import { JwtAuthGuard } from 'src/user/jwt.guard';
import { RolesGuard } from 'src/roles.guard';
import { Role } from 'src/role.enum';
import { Roles } from 'src/roles.decorator';
@Controller('mesa')
export class MesaController {
constructor(private readonly mesaService: MesaService) { }
@UseGuards(JwtAuthGuard)
@UseGuards(JwtAuthGuard, RolesGuard)
@Roles(Role.ADMINISTRADOR, Role.SUPER_ADMINISTRADOR,Role.ATENCION_USUARIOS,Role.SERVICIO_SOCIAL)
@Get()
async findAll() {
return this.mesaService.findAll();
}
@UseGuards(JwtAuthGuard)
@UseGuards(JwtAuthGuard, RolesGuard)
@Roles(Role.ADMINISTRADOR, Role.SUPER_ADMINISTRADOR,Role.ATENCION_USUARIOS,Role.SERVICIO_SOCIAL)
@Get('activo')
async findAllActivo() {
return this.mesaService.findAllActivo();
}
@UseGuards(JwtAuthGuard)
@UseGuards(JwtAuthGuard, RolesGuard)
@Roles(Role.ADMINISTRADOR, Role.SUPER_ADMINISTRADOR,Role.ATENCION_USUARIOS,Role.SERVICIO_SOCIAL)
@Get('uso')
async findActiveMesas() {
return this.mesaService.findActiveMesas();
}
@UseGuards(JwtAuthGuard)
@UseGuards(JwtAuthGuard, RolesGuard)
@Roles(Role.ADMINISTRADOR, Role.SUPER_ADMINISTRADOR)
@Patch(':id')
async updateActivo(
@Param('id') id: number,
@@ -34,7 +41,8 @@ export class MesaController {
return this.mesaService.updateActivo(id, updateMesaDto);
}
@UseGuards(JwtAuthGuard)
@UseGuards(JwtAuthGuard, RolesGuard)
@Roles(Role.ADMINISTRADOR, Role.SUPER_ADMINISTRADOR,Role.ATENCION_USUARIOS,Role.SERVICIO_SOCIAL)
@Patch(':id/activo')
toggleActivo(@Param('id') id: number) {
return this.mesaService.toggleActivo(+id);
+11 -1
View File
@@ -2,27 +2,37 @@ import { Body, Controller, Delete, Get, Param, Patch, Post, Put, UseGuards } fro
import { PeriodoService } from './periodo.service';
import { CreatePeriodoDto, ModifiedDateDto } from './dto/create-periodo.dto';
import { JwtAuthGuard } from 'src/user/jwt.guard';
import { RolesGuard } from 'src/roles.guard';
import { Roles } from 'src/roles.decorator';
import { Role } from 'src/role.enum';
@Controller('periodo')
export class PeriodoController {
constructor(private readonly periodoService: PeriodoService) { }
@UseGuards(JwtAuthGuard)
@UseGuards(JwtAuthGuard, RolesGuard)
@Roles(Role.ADMINISTRADOR, Role.SUPER_ADMINISTRADOR)
@Get()
findAll() {
return this.periodoService.findAll();
}
@UseGuards(JwtAuthGuard, RolesGuard)
@Roles(Role.ADMINISTRADOR, Role.SUPER_ADMINISTRADOR)
@Post()
create(@Body() data: CreatePeriodoDto) {
return this.periodoService.create(data);
}
@UseGuards(JwtAuthGuard, RolesGuard)
@Roles(Role.ADMINISTRADOR, Role.SUPER_ADMINISTRADOR)
@Delete("/:id_periodo")
delete(@Param("id_periodo") id_periodo: number) {
return this.periodoService.delete(id_periodo)
}
@UseGuards(JwtAuthGuard, RolesGuard)
@Roles(Role.ADMINISTRADOR, Role.SUPER_ADMINISTRADOR)
@Patch("/date/:id_periodo")
modifiedDate(@Body() data: ModifiedDateDto, @Param("id_periodo") id_periodo: number) {
return this.periodoService.modifiedDate(data, id_periodo)
+13 -5
View File
@@ -2,36 +2,44 @@ import { Controller, Get, Post, Body, Patch, Param, Delete, UseGuards } from '@n
import { ProgramaService } from './programa.service';
import { UpdateProgramaDto } from './dto/update-programa.dto';
import { JwtAuthGuard } from 'src/user/jwt.guard';
import { RolesGuard } from 'src/roles.guard';
import { Roles } from 'src/roles.decorator';
import { Role } from 'src/role.enum';
@Controller('programa')
export class ProgramaController {
constructor(private readonly programaService: ProgramaService) { }
@UseGuards(JwtAuthGuard)
@UseGuards(JwtAuthGuard, RolesGuard)
@Roles(Role.ADMINISTRADOR, Role.SUPER_ADMINISTRADOR)
@Get()
findAll() {
return this.programaService.findAll();
}
@UseGuards(JwtAuthGuard)
@UseGuards(JwtAuthGuard, RolesGuard)
@Roles(Role.ADMINISTRADOR, Role.SUPER_ADMINISTRADOR)
@Get(':id')
findOne(@Param('id') id: string) {
return this.programaService.findOne(+id);
}
@UseGuards(JwtAuthGuard)
@UseGuards(JwtAuthGuard, RolesGuard)
@Roles(Role.ADMINISTRADOR, Role.SUPER_ADMINISTRADOR)
@Post()
create(@Body() body) {
return this.programaService.create(body);
}
@UseGuards(JwtAuthGuard)
@UseGuards(JwtAuthGuard, RolesGuard)
@Roles(Role.ADMINISTRADOR, Role.SUPER_ADMINISTRADOR)
@Patch(':id')
update(@Param('id') id: string, @Body() updateProgramaDto: UpdateProgramaDto) {
return this.programaService.update(+id, updateProgramaDto);
}
@UseGuards(JwtAuthGuard)
@UseGuards(JwtAuthGuard, RolesGuard)
@Roles(Role.ADMINISTRADOR, Role.SUPER_ADMINISTRADOR)
@Delete(':id')
delete(@Param('id') id:string){
return this.programaService.delete(+id);
@@ -2,30 +2,38 @@ import { Controller, Get, Body, Patch, Param, UseGuards } from '@nestjs/common';
import { ProgramaEquipoService } from './programa_equipo.service';
import { UpdateProgramaEquipoDto, UpdateProgramasSalaDto } from './dto/update-programa_equipo.dto';
import { JwtAuthGuard } from 'src/user/jwt.guard';
import { RolesGuard } from 'src/roles.guard';
import { Roles } from 'src/roles.decorator';
import { Role } from 'src/role.enum';
@Controller('programa-equipo')
export class ProgramaEquipoController {
constructor(private readonly programaEquipoService: ProgramaEquipoService) {}
constructor(private readonly programaEquipoService: ProgramaEquipoService) { }
@UseGuards(JwtAuthGuard)
@UseGuards(JwtAuthGuard, RolesGuard)
@Roles(Role.ADMINISTRADOR, Role.SUPER_ADMINISTRADOR)
@Get('programas/:id')
findAllProgramByNumber(@Param('id') id: number) {
return this.programaEquipoService.findAllProgramByNumber(+id);
}
@UseGuards(JwtAuthGuard)
@UseGuards(JwtAuthGuard, RolesGuard)
@Roles(Role.ADMINISTRADOR, Role.SUPER_ADMINISTRADOR)
@Get('ubicacion/:id')
findAllProgramByUbicacion(@Param('id') id: string) {
return this.programaEquipoService.findAllProgramByUbication(id);
}
@UseGuards(JwtAuthGuard)
@UseGuards(JwtAuthGuard, RolesGuard)
@Roles(Role.ADMINISTRADOR, Role.SUPER_ADMINISTRADOR)
@Get(':id')
findOne(@Param('id') id: string) {
return this.programaEquipoService.findOne(id);
}
@UseGuards(JwtAuthGuard)
@UseGuards(JwtAuthGuard, RolesGuard)
@Roles(Role.ADMINISTRADOR, Role.SUPER_ADMINISTRADOR)
@Patch('equipo/:id')
updateMachine(
@Param('id') id: string,
@@ -37,7 +45,8 @@ export class ProgramaEquipoController {
);
}
@UseGuards(JwtAuthGuard)
@UseGuards(JwtAuthGuard, RolesGuard)
@Roles(Role.ADMINISTRADOR, Role.SUPER_ADMINISTRADOR)
@Patch('sala')
updateBySala(@Body() dto: UpdateProgramasSalaDto) {
return this.programaEquipoService.updateBySala(dto.sala, dto.programas);
+6 -3
View File
@@ -3,17 +3,20 @@ import {
Post,
Body,
UseGuards,
Req,
} from '@nestjs/common';
import { ReciboService } from './recibo.service';
import { FindReciboByRangeDto } from './dto/create-recibo.dto';
import { JwtAuthGuard } from 'src/user/jwt.guard';
import { RolesGuard } from 'src/roles.guard';
import { Roles } from 'src/roles.decorator';
import { Role } from 'src/role.enum';
@Controller('recibo')
export class ReciboController {
constructor(private readonly reciboService: ReciboService) {}
constructor(private readonly reciboService: ReciboService) { }
@UseGuards(JwtAuthGuard)
@UseGuards(JwtAuthGuard, RolesGuard)
@Roles(Role.ADMINISTRADOR, Role.SUPER_ADMINISTRADOR)
@Post('rango')
async findByDateRange(@Body() data: FindReciboByRangeDto) {
return this.reciboService.findByDateRange(data.desde, data.hasta);
+6 -4
View File
@@ -1,5 +1,7 @@
export enum Role {
ADMINISTRADOR = 'ADMINISTRADOR',
OPERADOR = 'OPERADOR',
}
ADMINISTRADOR = 1,
ATENCION_USUARIOS = 2,
SERVICIO_SOCIAL = 3,
SUPER_ADMINISTRADOR = 4,
PCPUMA = 5,
}
+2 -2
View File
@@ -6,7 +6,7 @@ import { ROLES_KEY } from './roles.decorator';
@Injectable()
export class RolesGuard implements CanActivate {
constructor(private reflector: Reflector) {}
constructor(private reflector: Reflector) { }
canActivate(context: ExecutionContext): boolean {
const requiredRoles = this.reflector.getAllAndOverride<Role[]>(ROLES_KEY, [
@@ -17,6 +17,6 @@ export class RolesGuard implements CanActivate {
return true;
}
const { user } = context.switchToHttp().getRequest();
return requiredRoles.some((role) => user.role?.includes(role));
return requiredRoles.some((role) => user.role === role);
}
}
+8 -3
View File
@@ -1,17 +1,22 @@
import { Controller, Get, Param, UseGuards } from '@nestjs/common';
import { SancionService } from './sancion.service';
import { JwtAuthGuard } from 'src/user/jwt.guard';
import { RolesGuard } from 'src/roles.guard';
import { Roles } from 'src/roles.decorator';
import { Role } from 'src/role.enum';
@Controller('sancion')
export class SancionController {
constructor(private readonly sancionService: SancionService) {}
constructor(private readonly sancionService: SancionService) { }
@UseGuards(JwtAuthGuard)
@UseGuards(JwtAuthGuard, RolesGuard)
@Roles(Role.ADMINISTRADOR, Role.SUPER_ADMINISTRADOR)
@Get()
find() {
return this.sancionService.find();
}
@UseGuards(JwtAuthGuard)
@UseGuards(JwtAuthGuard, RolesGuard)
@Roles(Role.ADMINISTRADOR, Role.SUPER_ADMINISTRADOR)
@Get(':id')
findOne(@Param('id') id: number) {
return this.sancionService.findOne(+id);
+6 -2
View File
@@ -1,12 +1,16 @@
import { Controller, Get, UseGuards } from '@nestjs/common';
import { ServicioService } from './servicio.service';
import { JwtAuthGuard } from 'src/user/jwt.guard';
import { RolesGuard } from 'src/roles.guard';
import { Roles } from 'src/roles.decorator';
import { Role } from 'src/role.enum';
@Controller('servicio')
export class ServicioController {
constructor(private readonly servicioService: ServicioService) {}
constructor(private readonly servicioService: ServicioService) { }
@UseGuards(JwtAuthGuard)
@UseGuards(JwtAuthGuard, RolesGuard)
@Roles(Role.ADMINISTRADOR, Role.SUPER_ADMINISTRADOR)
@Get()
findAll() {
return this.servicioService.findAll();
+12 -5
View File
@@ -11,18 +11,23 @@ import type { Response } from 'express';
import { UserService } from './user.service';
import { changePasswordDto, CreateUserDto, Login } from './dto/create-user.dto';
import { JwtAuthGuard } from './jwt.guard';
import { RolesGuard } from 'src/roles.guard';
import { Roles } from 'src/roles.decorator';
import { Role } from 'src/role.enum';
@Controller('user')
export class UserController {
constructor(private readonly userService: UserService) {}
constructor(private readonly userService: UserService) { }
@UseGuards(JwtAuthGuard)
@UseGuards(JwtAuthGuard, RolesGuard)
@Roles(Role.ADMINISTRADOR, Role.SUPER_ADMINISTRADOR)
@Get()
async getAll() {
return this.userService.getAll();
}
@UseGuards(JwtAuthGuard)
@UseGuards(JwtAuthGuard, RolesGuard)
@Roles(Role.ADMINISTRADOR, Role.SUPER_ADMINISTRADOR)
@Get('/perfil')
async getAllPerfil() {
return this.userService.getAllPerfil();
@@ -39,13 +44,15 @@ export class UserController {
return req.user.role;
}
@UseGuards(JwtAuthGuard)
@UseGuards(JwtAuthGuard, RolesGuard)
@Roles(Role.ADMINISTRADOR, Role.SUPER_ADMINISTRADOR)
@Post('/create')
async createUser(@Body() data: CreateUserDto) {
return this.userService.create(data);
}
@UseGuards(JwtAuthGuard)
@UseGuards(JwtAuthGuard, RolesGuard)
@Roles(Role.ADMINISTRADOR, Role.SUPER_ADMINISTRADOR)
@Post('/changePassword')
async changePassword(@Body() data: changePasswordDto, @Req() req) {
const id_usuario = req.user.id;