51 lines
1.6 KiB
TypeScript
51 lines
1.6 KiB
TypeScript
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, RolesGuard)
|
|
@Roles(Role.ADMINISTRADOR, Role.SUPER_ADMINISTRADOR,Role.ATENCION_USUARIOS,Role.SERVICIO_SOCIAL)
|
|
@Get()
|
|
async findAll() {
|
|
return this.mesaService.findAll();
|
|
}
|
|
|
|
@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, RolesGuard)
|
|
@Roles(Role.ADMINISTRADOR, Role.SUPER_ADMINISTRADOR,Role.ATENCION_USUARIOS,Role.SERVICIO_SOCIAL)
|
|
@Get('uso')
|
|
async findActiveMesas() {
|
|
return this.mesaService.findActiveMesas();
|
|
}
|
|
|
|
@UseGuards(JwtAuthGuard, RolesGuard)
|
|
@Roles(Role.ADMINISTRADOR, Role.SUPER_ADMINISTRADOR)
|
|
@Patch(':id')
|
|
async updateActivo(
|
|
@Param('id') id: number,
|
|
@Body() updateMesaDto: UpdateMesaDto,
|
|
) {
|
|
return this.mesaService.updateActivo(id, updateMesaDto);
|
|
}
|
|
|
|
@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);
|
|
}
|
|
}
|