Compare commits
12 Commits
Lino
...
8b6186ff6e
| Author | SHA1 | Date | |
|---|---|---|---|
| 8b6186ff6e | |||
| 0d9e82f527 | |||
| 0b984f1a9e | |||
| 65bdb47c00 | |||
| 73e0ede7ed | |||
| 645c4ed6c1 | |||
| 5b5d552b0c | |||
| 4bd78578a7 | |||
| 5f5295dcb4 | |||
| 70e1e2d7bf | |||
| 3bb95a3d50 | |||
| 81ad881d6a |
Generated
+25
-25
@@ -715,9 +715,9 @@
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@borewit/text-codec": {
|
||||
"version": "0.2.1",
|
||||
"resolved": "https://registry.npmjs.org/@borewit/text-codec/-/text-codec-0.2.1.tgz",
|
||||
"integrity": "sha512-k7vvKPbf7J2fZ5klGRD9AeKfUvojuZIQ3BT5u7Jfv+puwXkUBUT5PVyMDfJZpy30CBDXGMgw7fguK/lpOMBvgw==",
|
||||
"version": "0.2.2",
|
||||
"resolved": "https://registry.npmjs.org/@borewit/text-codec/-/text-codec-0.2.2.tgz",
|
||||
"integrity": "sha512-DDaRehssg1aNrH4+2hnj1B7vnUGEjU6OIlyRdkMd0aUdIUvKXrJfXsy8LVtXAy7DRvYVluWbMspsRhz2lcW0mQ==",
|
||||
"license": "MIT",
|
||||
"funding": {
|
||||
"type": "github",
|
||||
@@ -2279,12 +2279,12 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@nestjs/common": {
|
||||
"version": "11.1.14",
|
||||
"resolved": "https://registry.npmjs.org/@nestjs/common/-/common-11.1.14.tgz",
|
||||
"integrity": "sha512-IN/tlqd7Nl9gl6f0jsWEuOrQDaCI9vHzxv0fisHysfBQzfQIkqlv5A7w4Qge02BUQyczXT9HHPgHtWHCxhjRng==",
|
||||
"version": "11.1.17",
|
||||
"resolved": "https://registry.npmjs.org/@nestjs/common/-/common-11.1.17.tgz",
|
||||
"integrity": "sha512-hLODw5Abp8OQgA+mUO4tHou4krKgDtUcM9j5Ihxncst9XeyxYBTt2bwZm4e4EQr5E352S4Fyy6V3iFx9ggxKAg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"file-type": "21.3.0",
|
||||
"file-type": "21.3.2",
|
||||
"iterare": "1.2.1",
|
||||
"load-esm": "1.0.3",
|
||||
"tslib": "2.8.1",
|
||||
@@ -3995,9 +3995,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/anymatch/node_modules/picomatch": {
|
||||
"version": "2.3.1",
|
||||
"resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz",
|
||||
"integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==",
|
||||
"version": "2.3.2",
|
||||
"resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.2.tgz",
|
||||
"integrity": "sha512-V7+vQEJ06Z+c5tSye8S+nHUfI51xoXIXjHQ99cQtKUkQqqO1kO/KCJUfZXuB47h/YBlDhah2H3hdUGXn8ie0oA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
@@ -5701,9 +5701,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/file-type": {
|
||||
"version": "21.3.0",
|
||||
"resolved": "https://registry.npmjs.org/file-type/-/file-type-21.3.0.tgz",
|
||||
"integrity": "sha512-8kPJMIGz1Yt/aPEwOsrR97ZyZaD1Iqm8PClb1nYFclUCkBi0Ma5IsYNQzvSFS9ib51lWyIw5mIT9rWzI/xjpzA==",
|
||||
"version": "21.3.2",
|
||||
"resolved": "https://registry.npmjs.org/file-type/-/file-type-21.3.2.tgz",
|
||||
"integrity": "sha512-DLkUvGwep3poOV2wpzbHCOnSKGk1LzyXTv+aHFgN2VFl96wnp8YA9YjO2qPzg5PuL8q/SW9Pdi6WTkYOIh995w==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@tokenizer/inflate": "^0.4.1",
|
||||
@@ -5784,9 +5784,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/flatted": {
|
||||
"version": "3.3.4",
|
||||
"resolved": "https://registry.npmjs.org/flatted/-/flatted-3.3.4.tgz",
|
||||
"integrity": "sha512-3+mMldrTAPdta5kjX2G2J7iX4zxtnwpdA8Tr2ZSjkyPSanvbZAcy6flmtnXbEybHrDcU9641lxrMfFuUxVz9vA==",
|
||||
"version": "3.4.2",
|
||||
"resolved": "https://registry.npmjs.org/flatted/-/flatted-3.4.2.tgz",
|
||||
"integrity": "sha512-PjDse7RzhcPkIJwy5t7KPWQSZ9cAbzQXcafsetQoD7sOJRQlGikNbx7yZp2OotDnJyrDcbyRq3Ttb18iYOqkxA==",
|
||||
"dev": true,
|
||||
"license": "ISC"
|
||||
},
|
||||
@@ -7884,9 +7884,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/micromatch/node_modules/picomatch": {
|
||||
"version": "2.3.1",
|
||||
"resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz",
|
||||
"integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==",
|
||||
"version": "2.3.2",
|
||||
"resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.2.tgz",
|
||||
"integrity": "sha512-V7+vQEJ06Z+c5tSye8S+nHUfI51xoXIXjHQ99cQtKUkQqqO1kO/KCJUfZXuB47h/YBlDhah2H3hdUGXn8ie0oA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
@@ -9376,9 +9376,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/strtok3": {
|
||||
"version": "10.3.4",
|
||||
"resolved": "https://registry.npmjs.org/strtok3/-/strtok3-10.3.4.tgz",
|
||||
"integrity": "sha512-KIy5nylvC5le1OdaaoCJ07L+8iQzJHGH6pWDuzS+d07Cu7n1MZ2x26P8ZKIWfbK02+XIL8Mp4RkWeqdUCrDMfg==",
|
||||
"version": "10.3.5",
|
||||
"resolved": "https://registry.npmjs.org/strtok3/-/strtok3-10.3.5.tgz",
|
||||
"integrity": "sha512-ki4hZQfh5rX0QDLLkOCj+h+CVNkqmp/CMf8v8kZpkNVK6jGQooMytqzLZYUVYIZcFZ6yDB70EfD8POcFXiF5oA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@tokenizer/token": "^0.3.0"
|
||||
@@ -9701,9 +9701,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/tinyglobby/node_modules/picomatch": {
|
||||
"version": "4.0.3",
|
||||
"resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.3.tgz",
|
||||
"integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==",
|
||||
"version": "4.0.4",
|
||||
"resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.4.tgz",
|
||||
"integrity": "sha512-QP88BAKvMam/3NxH6vj2o21R6MjxZUAd6nlwAS/pnGvN9IVLocLHxGYIzFhg6fUQ+5th6P4dv4eW9jX3DSIj7A==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Controller, Get, Post, Body, Param, Patch, UseGuards } from '@nestjs/common';
|
||||
import { Controller, Get, Post, Body, Param, Patch, UseGuards, ParseIntPipe } from '@nestjs/common';
|
||||
import { AlumnoInscritoService } from './alumno_inscrito.service';
|
||||
import {
|
||||
CreateAlumnoInscritoDto,
|
||||
@@ -58,4 +58,27 @@ export class AlumnoInscritoController {
|
||||
): Promise<AlumnoInscrito[]> {
|
||||
return this.alumnoInscritoService.findById(id_cuenta);
|
||||
}
|
||||
|
||||
@Get('inscritos/periodo/:inicio/:fin')
|
||||
findByPeriodo(
|
||||
@Param('inicio', ParseIntPipe) inicio: number,
|
||||
@Param('fin', ParseIntPipe) fin: number,
|
||||
) {
|
||||
return this.alumnoInscritoService.findAllInscritosByRango(inicio, fin, 'periodo');
|
||||
}
|
||||
|
||||
@Get('inscritos/anio/:inicio/:fin')
|
||||
findByAnio(
|
||||
@Param('inicio', ParseIntPipe) inicio: number,
|
||||
@Param('fin', ParseIntPipe) fin: number,
|
||||
) {
|
||||
return this.alumnoInscritoService.findAllInscritosByRango(inicio, fin, 'anio');
|
||||
}
|
||||
|
||||
@Get('inscritos/mes/:anio')
|
||||
findByMes(
|
||||
@Param('anio', ParseIntPipe) anio: number,
|
||||
) {
|
||||
return this.alumnoInscritoService.findAllInscritosByRango(anio, 0, 'mes');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,10 +71,11 @@ async findAllInscritos(idPeriodo: number) {
|
||||
.where('periodo.id_periodo = :idPeriodo', { idPeriodo })
|
||||
.select([
|
||||
'carrera.carrera AS carrera',
|
||||
'periodo.semestre AS semestre',
|
||||
'plataforma.nombre AS profesor',
|
||||
'COUNT(DISTINCT CASE WHEN alumno.genero IN (\'F\', \'Femenino\') THEN alumno.id_cuenta END) AS femenino',
|
||||
'COUNT(DISTINCT CASE WHEN alumno.genero IN (\'M\', \'Masculino\') THEN alumno.id_cuenta END) AS masculino',
|
||||
'COUNT(DISTINCT alumno.id_cuenta) AS total'
|
||||
'COUNT(DISTINCT alumno.id_cuenta) AS total'
|
||||
])
|
||||
.groupBy('carrera.carrera')
|
||||
.addGroupBy('plataforma.nombre')
|
||||
@@ -193,7 +194,7 @@ async findAllInscritos(idPeriodo: number) {
|
||||
}
|
||||
}
|
||||
|
||||
//Borrar
|
||||
|
||||
async addTimeBorrar(
|
||||
idCuenta: number,
|
||||
idPlataforma: number,
|
||||
@@ -230,4 +231,119 @@ async findAllInscritos(idPeriodo: number) {
|
||||
const create = repo.create(data);
|
||||
return await repo.save(create);
|
||||
}
|
||||
async findAllInscritosByRango(
|
||||
inicio: number,
|
||||
fin: number,
|
||||
tipo: 'periodo' | 'mes' | 'anio',
|
||||
) {
|
||||
const qb = this.alumnoInscritoRepo
|
||||
.createQueryBuilder('inscritos')
|
||||
.innerJoin('inscritos.alumno', 'alumno')
|
||||
.innerJoin('alumno.carrera', 'carrera')
|
||||
.innerJoin('inscritos.plataforma', 'plataforma')
|
||||
.innerJoin('inscritos.periodo', 'periodo');
|
||||
|
||||
// ============================
|
||||
// 🟢 PERIODO
|
||||
// ============================
|
||||
if (tipo === 'periodo') {
|
||||
qb.where('periodo.id_periodo BETWEEN :inicio AND :fin', {
|
||||
inicio,
|
||||
fin,
|
||||
});
|
||||
|
||||
qb.select([
|
||||
'periodo.id_periodo AS id_periodo',
|
||||
'periodo.semestre AS semestre',
|
||||
'carrera.carrera AS carrera',
|
||||
'plataforma.nombre AS profesor',
|
||||
|
||||
`COUNT(DISTINCT CASE
|
||||
WHEN alumno.genero IN ('F', 'Femenino')
|
||||
THEN alumno.id_cuenta
|
||||
END) AS femenino`,
|
||||
|
||||
`COUNT(DISTINCT CASE
|
||||
WHEN alumno.genero IN ('M', 'Masculino')
|
||||
THEN alumno.id_cuenta
|
||||
END) AS masculino`,
|
||||
|
||||
'COUNT(DISTINCT alumno.id_cuenta) AS total',
|
||||
]);
|
||||
|
||||
qb.groupBy('periodo.id_periodo')
|
||||
.addGroupBy('carrera.carrera')
|
||||
.addGroupBy('plataforma.nombre')
|
||||
.orderBy('periodo.id_periodo', 'ASC');
|
||||
}
|
||||
|
||||
// ============================
|
||||
// 🔵 AÑO
|
||||
// ============================
|
||||
else if (tipo === 'anio') {
|
||||
qb.where(
|
||||
'periodo.fecha_inicio_servicio BETWEEN :inicio AND :fin',
|
||||
{
|
||||
inicio: `${inicio}-01-01`,
|
||||
fin: `${fin}-12-31`,
|
||||
},
|
||||
);
|
||||
|
||||
qb.select([
|
||||
'YEAR(periodo.fecha_inicio_servicio) AS semestre',
|
||||
'carrera.carrera AS carrera',
|
||||
'plataforma.nombre AS profesor',
|
||||
|
||||
`COUNT(DISTINCT CASE
|
||||
WHEN alumno.genero IN ('F', 'Femenino')
|
||||
THEN alumno.id_cuenta
|
||||
END) AS femenino`,
|
||||
|
||||
`COUNT(DISTINCT CASE
|
||||
WHEN alumno.genero IN ('M', 'Masculino')
|
||||
THEN alumno.id_cuenta
|
||||
END) AS masculino`,
|
||||
|
||||
'COUNT(DISTINCT alumno.id_cuenta) AS total',
|
||||
]);
|
||||
|
||||
qb.groupBy('YEAR(periodo.fecha_inicio_servicio)')
|
||||
.addGroupBy('carrera.carrera')
|
||||
.addGroupBy('plataforma.nombre')
|
||||
.orderBy('YEAR(periodo.fecha_inicio_servicio)', 'ASC')
|
||||
}
|
||||
|
||||
// ============================
|
||||
// 🟡 MES (UN SOLO AÑO)
|
||||
// ============================
|
||||
else if (tipo === 'mes') {
|
||||
qb.where('YEAR(periodo.fecha_inicio_servicio) = :anio', {
|
||||
anio: inicio, // aquí "inicio" es el año
|
||||
});
|
||||
|
||||
qb.select([
|
||||
'MONTH(periodo.fecha_inicio_servicio) AS semestre',
|
||||
'carrera.carrera AS carrera',
|
||||
'plataforma.nombre AS profesor',
|
||||
|
||||
`COUNT(DISTINCT CASE
|
||||
WHEN alumno.genero IN ('F', 'Femenino')
|
||||
THEN alumno.id_cuenta
|
||||
END) AS femenino`,
|
||||
|
||||
`COUNT(DISTINCT CASE
|
||||
WHEN alumno.genero IN ('M', 'Masculino')
|
||||
THEN alumno.id_cuenta
|
||||
END) AS masculino`,
|
||||
|
||||
'COUNT(DISTINCT alumno.id_cuenta) AS total',
|
||||
]);
|
||||
qb.groupBy('MONTH(periodo.fecha_inicio_servicio)')
|
||||
.addGroupBy('carrera.carrera')
|
||||
.addGroupBy('plataforma.nombre')
|
||||
.orderBy('YEAR(periodo.fecha_inicio_servicio)', 'ASC')
|
||||
}
|
||||
|
||||
return qb.getRawMany();
|
||||
}
|
||||
}
|
||||
+5
-1
@@ -86,6 +86,10 @@ import { Costo } from './costo/entities/costo.entity';
|
||||
Costo,
|
||||
],
|
||||
synchronize: false, //Never change to true in production!
|
||||
|
||||
extra: {
|
||||
connectionLimit: 10,
|
||||
},
|
||||
}),
|
||||
}),
|
||||
UserModule,
|
||||
@@ -113,5 +117,5 @@ import { Costo } from './costo/entities/costo.entity';
|
||||
controllers: [AppController],
|
||||
providers: [AppService],
|
||||
})
|
||||
export class AppModule {}
|
||||
export class AppModule { }
|
||||
//IO
|
||||
|
||||
@@ -51,7 +51,7 @@ export class EquipoService {
|
||||
.innerJoin('equipo.plataforma', 'p')
|
||||
.innerJoin('equipo.areaUbicacion', 'a')
|
||||
.where('equipo.activo = 1')
|
||||
.orderBy('equipo.ubicacion', 'ASC')
|
||||
.orderBy('equipo.ubicacion + 0', 'ASC')
|
||||
.getRawMany();
|
||||
}
|
||||
|
||||
@@ -108,7 +108,7 @@ export class EquipoService {
|
||||
return `equipo.id_equipo NOT IN ${subQuery}`;
|
||||
})
|
||||
|
||||
.orderBy('equipo.ubicacion', 'ASC')
|
||||
.orderBy('equipo.ubicacion + 0', 'ASC')
|
||||
|
||||
.getMany();
|
||||
|
||||
|
||||
@@ -13,13 +13,12 @@ export class ProgramaEquipoController {
|
||||
@UseGuards(JwtAuthGuard, RolesGuard)
|
||||
@Roles(Role.ADMINISTRADOR, Role.SUPER_ADMINISTRADOR)
|
||||
@Get('programas/:id')
|
||||
findAllProgramByNumber(@Param('id') id: number) {
|
||||
return this.programaEquipoService.findAllProgramByNumber(+id);
|
||||
async findAllProgramByNumber(@Param('id') id: number) {
|
||||
return await this.programaEquipoService.findAllProgramByNumber(+id);
|
||||
}
|
||||
|
||||
@UseGuards(JwtAuthGuard, RolesGuard)
|
||||
@Roles(Role.ADMINISTRADOR, Role.SUPER_ADMINISTRADOR)
|
||||
|
||||
@Get('ubicacion/:id')
|
||||
findAllProgramByUbicacion(@Param('id') id: string) {
|
||||
return this.programaEquipoService.findAllProgramByUbication(id);
|
||||
@@ -28,7 +27,7 @@ export class ProgramaEquipoController {
|
||||
@UseGuards(JwtAuthGuard, RolesGuard)
|
||||
@Roles(Role.ADMINISTRADOR, Role.SUPER_ADMINISTRADOR)
|
||||
@Get(':id')
|
||||
findOne(@Param('id') id: string) {
|
||||
findOne(@Param('id') id: number) {
|
||||
return this.programaEquipoService.findOne(id);
|
||||
}
|
||||
|
||||
|
||||
@@ -21,9 +21,9 @@ export class ProgramaEquipoService {
|
||||
return this.programaEquipoRepository.find();
|
||||
}
|
||||
|
||||
async findOne(ubicacion: string) {
|
||||
async findOne(id_equipo: number) {
|
||||
const equipo = await this.programaEquipoRepository.find({
|
||||
where: { equipo: { ubicacion } },
|
||||
where: { equipo: { id_equipo } },
|
||||
});
|
||||
|
||||
if (equipo.length === 0) {
|
||||
|
||||
@@ -6,6 +6,8 @@ import {
|
||||
UseGuards,
|
||||
Res,
|
||||
Req,
|
||||
Param,
|
||||
Patch,
|
||||
} from '@nestjs/common';
|
||||
import type { Response } from 'express';
|
||||
import { UserService } from './user.service';
|
||||
@@ -19,7 +21,15 @@ import { Role } from 'src/role.enum';
|
||||
export class UserController {
|
||||
constructor(private readonly userService: UserService) { }
|
||||
|
||||
@UseGuards(JwtAuthGuard, RolesGuard)
|
||||
@Roles(Role.ADMINISTRADOR, Role.SUPER_ADMINISTRADOR)
|
||||
@Get('/switch/:id')
|
||||
async getactive(@Param('id') id: number) {
|
||||
return this.userService.getactive(id);
|
||||
}
|
||||
|
||||
@UseGuards(JwtAuthGuard, RolesGuard)
|
||||
@Roles(Role.ADMINISTRADOR, Role.SUPER_ADMINISTRADOR)
|
||||
@Get()
|
||||
async getAll() {
|
||||
return this.userService.getAll();
|
||||
@@ -27,11 +37,18 @@ export class UserController {
|
||||
|
||||
@UseGuards(JwtAuthGuard, RolesGuard)
|
||||
@Roles(Role.ADMINISTRADOR, Role.SUPER_ADMINISTRADOR)
|
||||
@Get('/perfil')
|
||||
@Get('/perfil')
|
||||
async getAllPerfil() {
|
||||
return this.userService.getAllPerfil();
|
||||
}
|
||||
|
||||
@UseGuards(JwtAuthGuard, RolesGuard)
|
||||
@Roles(Role.ADMINISTRADOR, Role.SUPER_ADMINISTRADOR)
|
||||
@Patch(':id/activo')
|
||||
toggleActivo(@Param('id') id: number) {
|
||||
return this.userService.toggleActivo(id);
|
||||
}
|
||||
|
||||
@Post()
|
||||
async Login(@Body() data: Login, @Res() res: Response) {
|
||||
return this.userService.Login(data, res);
|
||||
|
||||
@@ -19,7 +19,36 @@ export class UserService {
|
||||
@InjectRepository(Perfil)
|
||||
private perfilRepository: Repository<Perfil>,
|
||||
private jwtService: JwtService,
|
||||
) {}
|
||||
) { }
|
||||
|
||||
async toggleActivo(id: number) {
|
||||
|
||||
const usuario = await this.userRepository.findOne({
|
||||
where: { id_usuario: id }
|
||||
});
|
||||
|
||||
if (!usuario) {
|
||||
throw new NotFoundException("no se encontro usuario")
|
||||
}
|
||||
|
||||
usuario.activo = usuario.activo === 1 ? 0 : 1;
|
||||
|
||||
return this.userRepository.save(usuario);
|
||||
}
|
||||
|
||||
async getactive(id: number) {
|
||||
const user = await this.userRepository.findOne({
|
||||
where: { id_usuario: id },
|
||||
});
|
||||
|
||||
if (!user) {
|
||||
throw new NotFoundException('Usuario no encontrado');
|
||||
}
|
||||
|
||||
user.activo = user.activo === 1 ? 0 : 1;
|
||||
|
||||
return this.userRepository.save(user);
|
||||
}
|
||||
|
||||
async findOneByNameandPassword(data: Login): Promise<User> {
|
||||
const { usuario, password } = data;
|
||||
@@ -28,7 +57,7 @@ export class UserService {
|
||||
where: { usuario, password },
|
||||
});
|
||||
|
||||
if(user?.activo === 0){
|
||||
if (user?.activo === 0) {
|
||||
throw new NotFoundException(`El usuario se encuentra desactivado`);
|
||||
}
|
||||
|
||||
@@ -115,7 +144,7 @@ export class UserService {
|
||||
}
|
||||
|
||||
async getAll() {
|
||||
return this.userRepository.find();
|
||||
return this.userRepository.find({select:['id_usuario','nombre','usuario','perfil','activo','password']});
|
||||
}
|
||||
|
||||
async getAllPerfil() {
|
||||
|
||||
Reference in New Issue
Block a user