Compare commits
3 Commits
admin_side
...
v1.1
| Author | SHA1 | Date | |
|---|---|---|---|
| c276116295 | |||
| 35926405cc | |||
| 93b2642860 |
@@ -20,6 +20,7 @@ export class AuthService {
|
||||
switch (loginDto.tipo_usuario) {
|
||||
case 1:
|
||||
// Administrador
|
||||
user = await this.usersService.findAdmin(loginDto);
|
||||
break;
|
||||
case 2:
|
||||
// Alumno
|
||||
@@ -27,9 +28,15 @@ export class AuthService {
|
||||
break;
|
||||
|
||||
case 3:
|
||||
// Trabajadores académicos o base
|
||||
// Trabajadores
|
||||
user = await this.usersService.findWorker(loginDto);
|
||||
break;
|
||||
|
||||
case 4:
|
||||
// Académicos
|
||||
user = await this.usersService.findWorker(loginDto);
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new BadRequestException();
|
||||
break;
|
||||
|
||||
@@ -49,6 +49,22 @@ export class ParticipacionService {
|
||||
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[]> {
|
||||
const queryBuilder =
|
||||
await this.tUReportesRepository.createQueryBuilder('tu');
|
||||
|
||||
@@ -1,26 +1,37 @@
|
||||
import { Controller, Get } from '@nestjs/common';
|
||||
import { Controller, Get, UseGuards } from "@nestjs/common";
|
||||
import { ParticipacionAlumno } from './ParticipacionAlumno.interface';
|
||||
import { ParticipacionService } from './participacionAlumno.service';
|
||||
import { AuthGuard } from "../auth/auth.guard";
|
||||
|
||||
@Controller('reportes')
|
||||
export class ReportesController {
|
||||
constructor(private readonly participacionService: ParticipacionService) {}
|
||||
|
||||
@UseGuards(AuthGuard)
|
||||
@Get('participacionAlumnos')
|
||||
async geParticipacionAlumno(): Promise<ParticipacionAlumno[]> {
|
||||
return this.participacionService.getParticipacionAlumno();
|
||||
}
|
||||
|
||||
@UseGuards(AuthGuard)
|
||||
@Get('participacionTrabajador')
|
||||
async geParticipacionTrabajador(): Promise<any> {
|
||||
return this.participacionService.getParticipacionTrabajador();
|
||||
}
|
||||
|
||||
@UseGuards(AuthGuard)
|
||||
@Get('participacionAcademico')
|
||||
async geParticipacionAcademico(): Promise<any> {
|
||||
return this.participacionService.getParticipacionAcademico();
|
||||
}
|
||||
|
||||
@UseGuards(AuthGuard)
|
||||
@Get('totalParticipantes')
|
||||
async getTotalParticipantes(): Promise<ParticipacionAlumno[]> {
|
||||
return this.participacionService.getTotalUsuarios();
|
||||
}
|
||||
|
||||
@UseGuards(AuthGuard)
|
||||
@Get('totalAlumnosPorCarrera')
|
||||
async getTotalAlumnosPorCarrera(): Promise<ParticipacionAlumno[]> {
|
||||
return this.participacionService.getTotalAlumnos();
|
||||
|
||||
@@ -40,4 +40,14 @@ export class UsersService {
|
||||
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