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
+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,