33 lines
763 B
TypeScript
33 lines
763 B
TypeScript
import {
|
|
Controller,
|
|
Get,
|
|
UseGuards,
|
|
Req,
|
|
NotFoundException,
|
|
} from '@nestjs/common';
|
|
import { MovimientoService } from './movimiento.service';
|
|
import { AuthGuard } from '@nestjs/passport';
|
|
|
|
@Controller('movimientos')
|
|
export class MovimientoController {
|
|
constructor(private readonly movimientoService: MovimientoService) {}
|
|
|
|
@UseGuards(AuthGuard('jwt'))
|
|
@Get('historial')
|
|
buscarEquipoPorToken(@Req() req: any) {
|
|
const id_usuario = req.user.id;
|
|
|
|
if (!id_usuario) {
|
|
throw new NotFoundException('token sin id_usuario');
|
|
}
|
|
|
|
return this.movimientoService.searchByIdUser(id_usuario);
|
|
}
|
|
|
|
@UseGuards(AuthGuard('jwt'))
|
|
@Get('dia')
|
|
EquiposCensadosPorDia() {
|
|
return this.movimientoService.countCensosPorDiaUnicos();
|
|
}
|
|
}
|