se agregò endpoint para traer ususarios y funcion diaria
This commit is contained in:
Binary file not shown.
Binary file not shown.
Generated
+301
-553
File diff suppressed because it is too large
Load Diff
@@ -26,6 +26,7 @@
|
||||
"@nestjs/mapped-types": "*",
|
||||
"@nestjs/passport": "^11.0.5",
|
||||
"@nestjs/platform-express": "^11.0.1",
|
||||
"@nestjs/schedule": "^6.0.1",
|
||||
"@nestjs/typeorm": "^11.0.0",
|
||||
"axios": "^1.13.1",
|
||||
"bcryptjs": "^3.0.2",
|
||||
|
||||
@@ -15,6 +15,12 @@ export class AuthController {
|
||||
return this.authService.registro(registroDto);
|
||||
}
|
||||
|
||||
@UseGuards(AuthGuard('jwt'))
|
||||
@Get('buscar')
|
||||
search() {
|
||||
return this.authService.findAll();
|
||||
}
|
||||
|
||||
@UseGuards(AuthGuard('jwt'))
|
||||
@Patch('update')
|
||||
update(@Body() registroDto: UpdateUsuarioDto) {
|
||||
|
||||
@@ -30,6 +30,10 @@ export class AuthService {
|
||||
return update_data;
|
||||
}
|
||||
|
||||
async findAll() {
|
||||
return await this.usuarioService.usuarios();
|
||||
}
|
||||
|
||||
async registro({ nombre, contraseña, tipoUsuario }: CreateUsuarioDto) {
|
||||
const usuario = await this.usuarioService.findOneByName(nombre);
|
||||
if (usuario) {
|
||||
|
||||
@@ -26,6 +26,7 @@ import {
|
||||
import { CreateEquipoDto } from './dto/create-equipo.dto';
|
||||
|
||||
import { MovimientoService } from 'src/movimiento/movimiento.service';
|
||||
import { Cron } from '@nestjs/schedule';
|
||||
|
||||
@Injectable()
|
||||
export class EquipoService {
|
||||
@@ -362,6 +363,25 @@ export class EquipoService {
|
||||
return this.exportarReporteAExcel(data, res);
|
||||
}
|
||||
|
||||
@Cron('0 0 0 * * *')
|
||||
async llenadoDeAntiguedad() {
|
||||
await this.equipoRepository
|
||||
.createQueryBuilder()
|
||||
.update(Equipo)
|
||||
.set({
|
||||
antiguedad: () => `
|
||||
CASE
|
||||
WHEN fecha_factura IS NULL THEN 'SINFECHA'
|
||||
WHEN TIMESTAMPDIFF(YEAR, fecha_factura, CURDATE()) < 2 THEN 'MENORES DE 2'
|
||||
WHEN TIMESTAMPDIFF(YEAR, fecha_factura, CURDATE()) BETWEEN 2 AND 3 THEN 'ENTRE 2 Y 3'
|
||||
WHEN TIMESTAMPDIFF(YEAR, fecha_factura, CURDATE()) BETWEEN 4 AND 5 THEN 'ENTRE 4 Y 5'
|
||||
WHEN TIMESTAMPDIFF(YEAR, fecha_factura, CURDATE()) >= 6 THEN 'ENTRE 6 Y MAYORES'
|
||||
END
|
||||
`,
|
||||
})
|
||||
.execute();
|
||||
}
|
||||
|
||||
async exportarReporteAExcel(data: any, res: Response) {
|
||||
const workbook = new ExcelJS.Workbook();
|
||||
|
||||
|
||||
@@ -19,6 +19,10 @@ export class UsuariosService {
|
||||
private readonly tipoUsuarioRepository: Repository<Tipo_Usuario>,
|
||||
) {}
|
||||
|
||||
async usuarios() {
|
||||
return await this.usuarioRepository.find({ relations: ['tipoUsuario'] });
|
||||
}
|
||||
|
||||
async actualizarUsuario(
|
||||
id: number,
|
||||
datos: { nombre?: string; contraseña?: string; id_tipo_usuario?: number },
|
||||
|
||||
Reference in New Issue
Block a user