Compare commits
6 Commits
admin_side
..
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 25e86d2eb2 | |||
| f77bb4b5ce | |||
| e10a06e1ff | |||
| c276116295 | |||
| 35926405cc | |||
| 93b2642860 |
+1
-1
@@ -8,7 +8,7 @@
|
||||
"scripts": {
|
||||
"build": "nest build",
|
||||
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
|
||||
"start": "nest start",
|
||||
"start": "source ~/.nvm/nvm.sh && nvm use 20.17.0 && nest start",
|
||||
"start:dev": "nest start --watch",
|
||||
"start:debug": "nest start --debug --watch",
|
||||
"start:prod": "node dist/main",
|
||||
|
||||
@@ -25,8 +25,6 @@ import { ComentariosModule } from './comentarios/comentarios.module';
|
||||
import { ComentarioLineasProgramaticas } from './entities/comentarioLineasProgramaticas.entity';
|
||||
import { ReportesController } from './reportes/reportes.controller';
|
||||
import { ReportesModule } from './reportes/reportes.module';
|
||||
import { Direccion } from './entities/direccion.entity';
|
||||
import { DireccionModule } from './direccion/direccion.module';
|
||||
config({ path: '.env' });
|
||||
@Module({
|
||||
imports: [
|
||||
@@ -37,7 +35,6 @@ config({ path: '.env' });
|
||||
LineasProgramaticasModule,
|
||||
CarreraModule,
|
||||
ReportesModule,
|
||||
DireccionModule,
|
||||
ConfigModule.forRoot({
|
||||
isGlobal: true,
|
||||
}),
|
||||
@@ -57,7 +54,6 @@ config({ path: '.env' });
|
||||
LineaProgramatica,
|
||||
TipoUsuarioEntity,
|
||||
UsuarioEntity,
|
||||
Direccion,
|
||||
],
|
||||
}),
|
||||
JwtModule.register({
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -1,69 +0,0 @@
|
||||
import {
|
||||
Body,
|
||||
Controller,
|
||||
Get,
|
||||
Header,
|
||||
HttpCode,
|
||||
Logger,
|
||||
Post,
|
||||
Put,
|
||||
Query,
|
||||
UseGuards,
|
||||
} from '@nestjs/common';
|
||||
import { AuthGuard } from '../auth/auth.guard';
|
||||
import { DireccionService } from './direccion.service';
|
||||
import { isUndefined } from '@nestjs/common/utils/shared.utils';
|
||||
import { DireccionDTO } from '../dtos/direccionDTO';
|
||||
import { Delete } from '@nestjs/common/decorators/http/request-mapping.decorator';
|
||||
|
||||
@Controller('direccion')
|
||||
export class DireccionController {
|
||||
constructor(private readonly direccionService: DireccionService) {}
|
||||
|
||||
@UseGuards(AuthGuard)
|
||||
@Header('content-type', 'application/json')
|
||||
@Get('direccion')
|
||||
@HttpCode(200)
|
||||
getDireccion() {
|
||||
Logger.log('Direccion', 'getDireccion');
|
||||
return this.direccionService.findDirecciones();
|
||||
}
|
||||
|
||||
@UseGuards(AuthGuard)
|
||||
@Header('content-type', 'application/json')
|
||||
@Get('direccionById')
|
||||
@HttpCode(200)
|
||||
getDireccionById(@Query('direccionId') direccionId: number) {
|
||||
Logger.log('Direccion', 'getDireccionById');
|
||||
if (!isUndefined(direccionId)) {
|
||||
return this.direccionService.findDireccionById(direccionId);
|
||||
}
|
||||
}
|
||||
|
||||
@UseGuards(AuthGuard)
|
||||
@Header('content-type', 'application/json')
|
||||
@Post('addDireccion')
|
||||
@HttpCode(200)
|
||||
setDireccion(@Body() direccion: DireccionDTO) {
|
||||
Logger.log('Direccion', 'setDireccion');
|
||||
return this.direccionService.addDireccion(direccion);
|
||||
}
|
||||
|
||||
@UseGuards(AuthGuard)
|
||||
@Header('content-type', 'application/json')
|
||||
@Put('updateDireccion')
|
||||
@HttpCode(200)
|
||||
updateDireccion(@Body() direccion: DireccionDTO) {
|
||||
Logger.log('Direccion', 'updateDireccion');
|
||||
return this.direccionService.updateDireccion(direccion);
|
||||
}
|
||||
|
||||
@UseGuards(AuthGuard)
|
||||
@Header('content-type', 'application/json')
|
||||
@Delete('deleteDireccion')
|
||||
@HttpCode(200)
|
||||
deleteDireccion(@Body() direccion: DireccionDTO) {
|
||||
Logger.log('Direccion', 'deleteDireccion');
|
||||
return this.direccionService.deleteDireccion(direccion);
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||
import { Direccion } from '../entities/direccion.entity';
|
||||
import { DireccionService } from './direccion.service';
|
||||
import { DireccionController } from './direccion.controller';
|
||||
|
||||
@Module({
|
||||
imports: [TypeOrmModule.forFeature([Direccion])],
|
||||
providers: [DireccionService],
|
||||
controllers: [DireccionController],
|
||||
exports: [TypeOrmModule.forFeature([DireccionService])],
|
||||
})
|
||||
export class DireccionModule {}
|
||||
@@ -1,36 +0,0 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
import { DeleteResult, Repository, UpdateResult } from 'typeorm';
|
||||
import { Direccion } from '../entities/direccion.entity';
|
||||
import { DireccionDTO } from '../dtos/direccionDTO';
|
||||
|
||||
@Injectable()
|
||||
export class DireccionService {
|
||||
constructor(
|
||||
@InjectRepository(Direccion)
|
||||
private direccionRepository: Repository<Direccion>,
|
||||
) {}
|
||||
|
||||
findDirecciones(): Promise<Direccion[]> {
|
||||
return this.direccionRepository.find({});
|
||||
}
|
||||
|
||||
findDireccionById(direccionId: number): Promise<Direccion[]> {
|
||||
return this.direccionRepository.findBy({ id: direccionId });
|
||||
|
||||
}
|
||||
|
||||
addDireccion(direccion: DireccionDTO): Promise<Direccion> {
|
||||
return this.direccionRepository.save(direccion);
|
||||
}
|
||||
|
||||
updateDireccion(direccion: DireccionDTO): Promise<UpdateResult> {
|
||||
return this.direccionRepository.update({ direccion });
|
||||
}
|
||||
|
||||
deleteDireccion(direccion: Direccion): Promise<DeleteResult> {
|
||||
return this.direccionRepository.delete({
|
||||
id: direccion.id,
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
import { IsDefined, IsInt, IsNotEmpty, IsString } from "@nestjs/class-validator";
|
||||
|
||||
export class DireccionDTO {
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
@IsDefined()
|
||||
readonly primer_nombre: string;
|
||||
|
||||
@IsString()
|
||||
readonly segundo_nombre: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
@IsDefined()
|
||||
readonly apellido_paterno: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
@IsDefined()
|
||||
readonly apellido_materno: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
@IsDefined()
|
||||
readonly inicio_periodo: Date;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
@IsDefined()
|
||||
readonly fin_periodo: Date;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
@IsDefined()
|
||||
readonly inicio_periodo_encuesta: Date;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
@IsDefined()
|
||||
readonly fin_periodo_encuesta: Date;
|
||||
|
||||
@IsInt()
|
||||
readonly id: number;
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
import { Column, Entity, PrimaryGeneratedColumn } from 'typeorm';
|
||||
|
||||
@Entity('direccion')
|
||||
export class Direccion {
|
||||
|
||||
@PrimaryGeneratedColumn('increment', { type: 'int' })
|
||||
id: number;
|
||||
|
||||
@Column('varchar', { length: 100 })
|
||||
primer_nombre: string;
|
||||
|
||||
@Column('varchar', { length: 100 })
|
||||
segundo_nombre: string;
|
||||
|
||||
@Column('varchar', { length: 100 })
|
||||
apellido_paterno: string;
|
||||
|
||||
@Column('varchar', { length: 100 })
|
||||
apellido_materno: string;
|
||||
|
||||
@Column('date')
|
||||
inicio_periodo: Date;
|
||||
|
||||
@Column('date')
|
||||
fin_periodo: Date;
|
||||
|
||||
@Column('date')
|
||||
inicio_periodo_encuesta: Date;
|
||||
|
||||
@Column('date')
|
||||
fin_periodo_encuesta: Date;
|
||||
}
|
||||
@@ -1,12 +1,5 @@
|
||||
import {
|
||||
Entity,
|
||||
Column,
|
||||
PrimaryGeneratedColumn,
|
||||
OneToMany,
|
||||
ManyToOne,
|
||||
} from 'typeorm';
|
||||
import { Entity, Column, PrimaryGeneratedColumn, OneToMany } from 'typeorm';
|
||||
import { LineaProgramatica } from './LineaProgramatica.entity';
|
||||
import { Direccion } from './direccion.entity';
|
||||
|
||||
@Entity('ejes_estrategicos')
|
||||
export class EjeEstrategico {
|
||||
@@ -24,7 +17,4 @@ export class EjeEstrategico {
|
||||
(lineaProgramatica) => lineaProgramatica.ejeEstrategico,
|
||||
)
|
||||
lineasProgramaticas: LineaProgramatica[];
|
||||
|
||||
@ManyToOne(() => Direccion, (direccion) => direccion.id)
|
||||
direccion: Direccion;
|
||||
}
|
||||
|
||||
@@ -5,6 +5,8 @@ import { InjectRepository } from '@nestjs/typeorm';
|
||||
import { UsuarioEntity } from '../entities/usuario.entity';
|
||||
import { TipoUsuarioEntity } from '../entities/tipoUsuario.entity';
|
||||
import { Carrera } from '../entities/carreras.entity';
|
||||
import { ComentarioLineasProgramaticas } from '../entities/comentarioLineasProgramaticas.entity';
|
||||
import { LineaProgramatica } from '../entities/LineaProgramatica.entity';
|
||||
|
||||
@Injectable()
|
||||
export class ParticipacionService {
|
||||
@@ -15,6 +17,8 @@ export class ParticipacionService {
|
||||
private readonly tUReportesRepository: Repository<any>,
|
||||
@InjectRepository(Carrera)
|
||||
private readonly carrearasReportesRepository: Repository<any>,
|
||||
@InjectRepository(ComentarioLineasProgramaticas)
|
||||
private readonly comentarioLineaProgramaticaReportesRepository: Repository<any>,
|
||||
) {}
|
||||
|
||||
async getParticipacionAlumno(): Promise<ParticipacionAlumno[]> {
|
||||
@@ -49,6 +53,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');
|
||||
@@ -72,4 +92,27 @@ export class ParticipacionService {
|
||||
.groupBy('c.id, c.nombre')
|
||||
.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 { 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();
|
||||
}
|
||||
|
||||
@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 { TipoUsuarioEntity } from '../entities/tipoUsuario.entity';
|
||||
import { Carrera } from '../entities/carreras.entity';
|
||||
import { LineaProgramatica } from "../entities/LineaProgramatica.entity";
|
||||
import { ComentarioLineasProgramaticas } from "../entities/comentarioLineasProgramaticas.entity";
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
TypeOrmModule.forFeature([UsuarioEntity, TipoUsuarioEntity, Carrera]),
|
||||
TypeOrmModule.forFeature([UsuarioEntity, TipoUsuarioEntity, Carrera, ComentarioLineasProgramaticas]),
|
||||
],
|
||||
providers: [ParticipacionService],
|
||||
controllers: [ReportesController],
|
||||
|
||||
@@ -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