Compare commits
6 Commits
admin_side
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 25e86d2eb2 | |||
| f77bb4b5ce | |||
| e10a06e1ff | |||
| c276116295 | |||
| 35926405cc | |||
| 93b2642860 |
@@ -20,6 +20,7 @@ export class AuthService {
|
|||||||
switch (loginDto.tipo_usuario) {
|
switch (loginDto.tipo_usuario) {
|
||||||
case 1:
|
case 1:
|
||||||
// Administrador
|
// Administrador
|
||||||
|
user = await this.usersService.findAdmin(loginDto);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
// Alumno
|
// Alumno
|
||||||
@@ -27,9 +28,15 @@ export class AuthService {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 3:
|
case 3:
|
||||||
// Trabajadores académicos o base
|
// Trabajadores
|
||||||
user = await this.usersService.findWorker(loginDto);
|
user = await this.usersService.findWorker(loginDto);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 4:
|
||||||
|
// Académicos
|
||||||
|
user = await this.usersService.findWorker(loginDto);
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw new BadRequestException();
|
throw new BadRequestException();
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ import { InjectRepository } from '@nestjs/typeorm';
|
|||||||
import { UsuarioEntity } from '../entities/usuario.entity';
|
import { UsuarioEntity } from '../entities/usuario.entity';
|
||||||
import { TipoUsuarioEntity } from '../entities/tipoUsuario.entity';
|
import { TipoUsuarioEntity } from '../entities/tipoUsuario.entity';
|
||||||
import { Carrera } from '../entities/carreras.entity';
|
import { Carrera } from '../entities/carreras.entity';
|
||||||
|
import { ComentarioLineasProgramaticas } from '../entities/comentarioLineasProgramaticas.entity';
|
||||||
|
import { LineaProgramatica } from '../entities/LineaProgramatica.entity';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class ParticipacionService {
|
export class ParticipacionService {
|
||||||
@@ -15,6 +17,8 @@ export class ParticipacionService {
|
|||||||
private readonly tUReportesRepository: Repository<any>,
|
private readonly tUReportesRepository: Repository<any>,
|
||||||
@InjectRepository(Carrera)
|
@InjectRepository(Carrera)
|
||||||
private readonly carrearasReportesRepository: Repository<any>,
|
private readonly carrearasReportesRepository: Repository<any>,
|
||||||
|
@InjectRepository(ComentarioLineasProgramaticas)
|
||||||
|
private readonly comentarioLineaProgramaticaReportesRepository: Repository<any>,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
async getParticipacionAlumno(): Promise<ParticipacionAlumno[]> {
|
async getParticipacionAlumno(): Promise<ParticipacionAlumno[]> {
|
||||||
@@ -49,6 +53,22 @@ export class ParticipacionService {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async getParticipacionAcademico(): Promise<SelectQueryBuilder<any>> {
|
||||||
|
const result = await this.reportesRepository
|
||||||
|
.createQueryBuilder('usuarios')
|
||||||
|
.select('COUNT(DISTINCT usuarios.id)', 'Participacion Trabajadores')
|
||||||
|
.addSelect(
|
||||||
|
`
|
||||||
|
(COUNT(DISTINCT usuarios.id) * 100.0 / (SELECT COUNT(*) FROM usuarios WHERE usuarios.tipo_usuario_id = 4)) AS PorcentajeParticipacion
|
||||||
|
`,
|
||||||
|
)
|
||||||
|
.innerJoin('usuarios.comentarios', 'clp')
|
||||||
|
.where('usuarios.tipo_usuario_id = 4')
|
||||||
|
.getRawOne();
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
async getTotalUsuarios(): Promise<ParticipacionAlumno[]> {
|
async getTotalUsuarios(): Promise<ParticipacionAlumno[]> {
|
||||||
const queryBuilder =
|
const queryBuilder =
|
||||||
await this.tUReportesRepository.createQueryBuilder('tu');
|
await this.tUReportesRepository.createQueryBuilder('tu');
|
||||||
@@ -72,4 +92,27 @@ export class ParticipacionService {
|
|||||||
.groupBy('c.id, c.nombre')
|
.groupBy('c.id, c.nombre')
|
||||||
.getRawMany()) as any[]; // Cast to
|
.getRawMany()) as any[]; // Cast to
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async getReporteGeneral(): Promise<any> {
|
||||||
|
const result = await this.comentarioLineaProgramaticaReportesRepository
|
||||||
|
.createQueryBuilder('clp')
|
||||||
|
.innerJoin('clp.lineaProgramatica', 'lp')
|
||||||
|
.innerJoin('lp.ejeEstrategico', 'ee')
|
||||||
|
.innerJoin('clp.usuario', 'u')
|
||||||
|
.innerJoin('u.tipoUsuario', 'tu')
|
||||||
|
.leftJoin('u.carrera', 'c')
|
||||||
|
.select([
|
||||||
|
'clp.id as Id_Comentario',
|
||||||
|
'clp.comentario as Comentario',
|
||||||
|
'lp.descripcion AS Linea_Programatica',
|
||||||
|
'ee.nombre AS Eje_Estrategico',
|
||||||
|
'ee.objetivo as Objetivo',
|
||||||
|
'u.numero_identificacion AS numero_Cuenta_O_Trabajador',
|
||||||
|
'tu.tipo as Tipo',
|
||||||
|
"CASE WHEN tu.id = 2 THEN c.nombre ELSE 'No aplica' END AS carrera",
|
||||||
|
])
|
||||||
|
.getRawMany();
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,28 +1,45 @@
|
|||||||
import { Controller, Get } from '@nestjs/common';
|
import { Controller, Get, UseGuards } from "@nestjs/common";
|
||||||
import { ParticipacionAlumno } from './ParticipacionAlumno.interface';
|
import { ParticipacionAlumno } from './ParticipacionAlumno.interface';
|
||||||
import { ParticipacionService } from './participacionAlumno.service';
|
import { ParticipacionService } from './participacionAlumno.service';
|
||||||
|
import { AuthGuard } from "../auth/auth.guard";
|
||||||
|
|
||||||
@Controller('reportes')
|
@Controller('reportes')
|
||||||
export class ReportesController {
|
export class ReportesController {
|
||||||
constructor(private readonly participacionService: ParticipacionService) {}
|
constructor(private readonly participacionService: ParticipacionService) {}
|
||||||
|
|
||||||
|
@UseGuards(AuthGuard)
|
||||||
@Get('participacionAlumnos')
|
@Get('participacionAlumnos')
|
||||||
async geParticipacionAlumno(): Promise<ParticipacionAlumno[]> {
|
async geParticipacionAlumno(): Promise<ParticipacionAlumno[]> {
|
||||||
return this.participacionService.getParticipacionAlumno();
|
return this.participacionService.getParticipacionAlumno();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@UseGuards(AuthGuard)
|
||||||
@Get('participacionTrabajador')
|
@Get('participacionTrabajador')
|
||||||
async geParticipacionTrabajador(): Promise<any> {
|
async geParticipacionTrabajador(): Promise<any> {
|
||||||
return this.participacionService.getParticipacionTrabajador();
|
return this.participacionService.getParticipacionTrabajador();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@UseGuards(AuthGuard)
|
||||||
|
@Get('participacionAcademico')
|
||||||
|
async geParticipacionAcademico(): Promise<any> {
|
||||||
|
return this.participacionService.getParticipacionAcademico();
|
||||||
|
}
|
||||||
|
|
||||||
|
@UseGuards(AuthGuard)
|
||||||
@Get('totalParticipantes')
|
@Get('totalParticipantes')
|
||||||
async getTotalParticipantes(): Promise<ParticipacionAlumno[]> {
|
async getTotalParticipantes(): Promise<ParticipacionAlumno[]> {
|
||||||
return this.participacionService.getTotalUsuarios();
|
return this.participacionService.getTotalUsuarios();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@UseGuards(AuthGuard)
|
||||||
@Get('totalAlumnosPorCarrera')
|
@Get('totalAlumnosPorCarrera')
|
||||||
async getTotalAlumnosPorCarrera(): Promise<ParticipacionAlumno[]> {
|
async getTotalAlumnosPorCarrera(): Promise<ParticipacionAlumno[]> {
|
||||||
return this.participacionService.getTotalAlumnos();
|
return this.participacionService.getTotalAlumnos();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@UseGuards(AuthGuard)
|
||||||
|
@Get('reporteGeneral')
|
||||||
|
async getReporteGeneral(): Promise<any> {
|
||||||
|
return this.participacionService.getReporteGeneral();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,10 +5,12 @@ import { ReportesController } from './reportes.controller';
|
|||||||
import { UsuarioEntity } from '../entities/usuario.entity';
|
import { UsuarioEntity } from '../entities/usuario.entity';
|
||||||
import { TipoUsuarioEntity } from '../entities/tipoUsuario.entity';
|
import { TipoUsuarioEntity } from '../entities/tipoUsuario.entity';
|
||||||
import { Carrera } from '../entities/carreras.entity';
|
import { Carrera } from '../entities/carreras.entity';
|
||||||
|
import { LineaProgramatica } from "../entities/LineaProgramatica.entity";
|
||||||
|
import { ComentarioLineasProgramaticas } from "../entities/comentarioLineasProgramaticas.entity";
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
imports: [
|
imports: [
|
||||||
TypeOrmModule.forFeature([UsuarioEntity, TipoUsuarioEntity, Carrera]),
|
TypeOrmModule.forFeature([UsuarioEntity, TipoUsuarioEntity, Carrera, ComentarioLineasProgramaticas]),
|
||||||
],
|
],
|
||||||
providers: [ParticipacionService],
|
providers: [ParticipacionService],
|
||||||
controllers: [ReportesController],
|
controllers: [ReportesController],
|
||||||
|
|||||||
@@ -40,4 +40,14 @@ export class UsersService {
|
|||||||
rfc,
|
rfc,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
findAdmin(loginDto: LoginDTO): Promise<UsuarioEntity | null> {
|
||||||
|
const numero_identificacion = loginDto.numero_identificacion;
|
||||||
|
const rfc = loginDto.rfc;
|
||||||
|
return this.usersRepository.findOneBy({
|
||||||
|
numero_identificacion,
|
||||||
|
rfc,
|
||||||
|
tipo_usuario_id:1
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user