80 lines
1.9 KiB
TypeScript
80 lines
1.9 KiB
TypeScript
import { Body, Controller, Get, Param, Patch, Post, UseGuards } from '@nestjs/common';
|
|
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';
|
|
|
|
@Controller('equipo')
|
|
export class EquipoController {
|
|
constructor(private readonly equipoService: EquipoService) { }
|
|
|
|
@UseGuards(JwtAuthGuard)
|
|
@Get()
|
|
findAll(): Promise<Equipo[]> {
|
|
return this.equipoService.findAll();
|
|
}
|
|
|
|
@UseGuards(JwtAuthGuard)
|
|
@Get('/active')
|
|
findActive() {
|
|
return this.equipoService.findActive();
|
|
}
|
|
|
|
@UseGuards(JwtAuthGuard)
|
|
@Get('/disable')
|
|
findDisable() {
|
|
return this.equipoService.findDisable();
|
|
}
|
|
|
|
@UseGuards(JwtAuthGuard)
|
|
@Get('/student/:id')
|
|
findOnlyUsable(@Param('id') id: number): Promise<Equipo[]> {
|
|
return this.equipoService.findOnlyUsable(+id);
|
|
}
|
|
|
|
@UseGuards(JwtAuthGuard)
|
|
@Get('/busy')
|
|
findOnlyBusy(): Promise<Equipo[]> {
|
|
return this.equipoService.findOnlyBusy();
|
|
}
|
|
|
|
@UseGuards(JwtAuthGuard)
|
|
@Get(':id')
|
|
findOne(@Param('id') id: string): Promise<Equipo> {
|
|
return this.equipoService.findOne(id);
|
|
}
|
|
|
|
@UseGuards(JwtAuthGuard)
|
|
@Post()
|
|
create(@Body() equipo: CreateEquipoDto) {
|
|
return this.equipoService.create(equipo);
|
|
}
|
|
|
|
@UseGuards(JwtAuthGuard)
|
|
@Patch()
|
|
update(@Body() equipo: CreateEquipoDto) {
|
|
return this.equipoService.update(equipo);
|
|
}
|
|
|
|
@UseGuards(JwtAuthGuard)
|
|
@Patch(':id/activo')
|
|
toggleActivo(@Param('id') id: number) {
|
|
return this.equipoService.toggleActivo(+id);
|
|
}
|
|
|
|
@UseGuards(JwtAuthGuard)
|
|
@Patch('actualizar-area')
|
|
actualizarPorArea(
|
|
@Body() updateAreaEquiposDto: UpdateAreaEquiposDto,
|
|
) {
|
|
const { id_area_ubicacion, activo } = updateAreaEquiposDto;
|
|
|
|
return this.equipoService.actualizarEquiposPorArea(
|
|
id_area_ubicacion,
|
|
activo,
|
|
);
|
|
}
|
|
|
|
}
|
|
//IO
|