se hizo el service cuestionario-alumno
This commit is contained in:
@@ -54,3 +54,5 @@ pids
|
||||
|
||||
# Diagnostic reports (https://nodejs.org/api/report.html)
|
||||
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
|
||||
#Base de datos
|
||||
mysql
|
||||
@@ -0,0 +1,14 @@
|
||||
services:
|
||||
mysql:
|
||||
image: mariadb:latest
|
||||
container_name: Iris_back
|
||||
restart: always
|
||||
environment:
|
||||
MYSQL_ROOT_PASSWORD: root
|
||||
MYSQL_DATABASE: Iris
|
||||
MYSQL_USER: user_crud
|
||||
MYSQL_PASSWORD: root
|
||||
volumes:
|
||||
- ./mysql:/var/lib/mysql
|
||||
ports:
|
||||
- "3307:3306"
|
||||
Generated
+1030
-166
File diff suppressed because it is too large
Load Diff
+15
-2
@@ -21,10 +21,23 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@nestjs/common": "^11.0.1",
|
||||
"@nestjs/core": "^11.0.1",
|
||||
"@nestjs/config": "^4.0.2",
|
||||
"@nestjs/core": "^11.1.1",
|
||||
"@nestjs/jwt": "^11.0.0",
|
||||
"@nestjs/mapped-types": "*",
|
||||
"@nestjs/passport": "^11.0.5",
|
||||
"@nestjs/platform-express": "^11.0.1",
|
||||
"@nestjs/typeorm": "^11.0.0",
|
||||
"class-validator": "^0.14.2",
|
||||
"convert-array-to-csv": "^2.0.0",
|
||||
"googleapis": "^148.0.0",
|
||||
"moment": "^2.30.1",
|
||||
"mysql": "^2.18.1",
|
||||
"passport": "^0.7.0",
|
||||
"passport-jwt": "^4.0.1",
|
||||
"reflect-metadata": "^0.2.2",
|
||||
"rxjs": "^7.8.1"
|
||||
"rxjs": "^7.8.1",
|
||||
"typeorm": "^0.3.23"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@eslint/eslintrc": "^3.2.0",
|
||||
|
||||
+55
-1
@@ -1,9 +1,63 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { AppController } from './app.controller';
|
||||
import { AppService } from './app.service';
|
||||
import { ConfigModule } from '@nestjs/config';
|
||||
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||
import { CarreraModule } from './carrera/carrera.module';
|
||||
import { CasoEspecialModule } from './caso-especial/caso-especial.module';
|
||||
import { CuestionarioAlumnoModule } from './cuestionario-alumno/cuestionario-alumno.module';
|
||||
import { CuestionarioAlumno2Module } from './cuestionario-alumno2/cuestionario-alumno2.module';
|
||||
import { CuestionarioProgramaModule } from './cuestionario-programa/cuestionario-programa.module';
|
||||
import { CuestionarioPrograma2Module } from './cuestionario-programa2/cuestionario-programa2.module';
|
||||
import { ProgramaModule } from './programa/programa.module';
|
||||
import { ServicioModule } from './servicio/servicio.module';
|
||||
import { StatusModule } from './status/status.module';
|
||||
import { TipoUsuarioModule } from './tipo-usuario/tipo-usuario.module';
|
||||
import { UsuarioModule } from './usuario/usuario.module';
|
||||
|
||||
@Module({
|
||||
imports: [],
|
||||
imports: [
|
||||
ConfigModule.forRoot(
|
||||
{isGlobal: true}
|
||||
),
|
||||
|
||||
TypeOrmModule.forRoot({
|
||||
type: 'mysql',
|
||||
host: process.env.db_host,
|
||||
username: process.env.db_username,
|
||||
database: process.env.db_database,
|
||||
password: process.env.db_password,
|
||||
port: Number(process.env.db_port),
|
||||
synchronize: true,
|
||||
dropSchema: false, // elimina la base de datos
|
||||
// logging: true, // Habilita los logs para depuración
|
||||
autoLoadEntities: true, // Carga automáticamente las entidades
|
||||
|
||||
}),
|
||||
|
||||
CarreraModule,
|
||||
|
||||
CasoEspecialModule,
|
||||
|
||||
CuestionarioAlumnoModule,
|
||||
|
||||
CuestionarioAlumno2Module,
|
||||
|
||||
CuestionarioProgramaModule,
|
||||
|
||||
CuestionarioPrograma2Module,
|
||||
|
||||
ProgramaModule,
|
||||
|
||||
ServicioModule,
|
||||
|
||||
StatusModule,
|
||||
|
||||
TipoUsuarioModule,
|
||||
|
||||
UsuarioModule,
|
||||
|
||||
],
|
||||
controllers: [AppController],
|
||||
providers: [AppService],
|
||||
})
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
import { JwtModule } from '@nestjs/jwt';
|
||||
import { Module } from '@nestjs/common';
|
||||
import { AuthService } from './auth.service';
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
JwtModule.register({
|
||||
secret: 'secretoSuperSeguro', // Usa un .env en producción
|
||||
signOptions: { expiresIn: '1h' },
|
||||
}),
|
||||
],
|
||||
providers: [AuthService],
|
||||
exports: [AuthService],
|
||||
})
|
||||
export class AuthModule {}
|
||||
@@ -0,0 +1,31 @@
|
||||
import { Injectable, UnauthorizedException } from '@nestjs/common';
|
||||
import { JwtService } from '@nestjs/jwt';
|
||||
|
||||
@Injectable()
|
||||
export class AuthService {
|
||||
constructor(private readonly jwtService: JwtService) {}
|
||||
|
||||
async jwtVerificar(token:string){
|
||||
try{
|
||||
const payload= this.jwtService.verify(token)
|
||||
return payload;
|
||||
}catch(err){
|
||||
if (err.name === 'TokenExpiredError') {
|
||||
throw new UnauthorizedException('El token ha expirado');
|
||||
} else if (err.name === 'JsonWebTokenError') {
|
||||
throw new UnauthorizedException('Token inválido');
|
||||
} else {
|
||||
throw new UnauthorizedException('Error al verificar el token');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
async jwtCreate(idUsuario: number, idTipoUsuario:number) {
|
||||
const payload = { Usuario:idUsuario , tipoUsuario: idTipoUsuario };
|
||||
return {
|
||||
access_token: this.jwtService.sign(payload),
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
import { Controller, Get, Post, Body, Patch, Param, Delete } from '@nestjs/common';
|
||||
import { CarreraService } from './carrera.service';
|
||||
import { CreateCarreraDto } from './dto/create-carrera.dto';
|
||||
import { UpdateCarreraDto } from './dto/update-carrera.dto';
|
||||
|
||||
@Controller('carrera')
|
||||
export class CarreraController {
|
||||
constructor(private readonly carreraService: CarreraService) {}
|
||||
|
||||
@Post()
|
||||
create(@Body() createCarreraDto: CreateCarreraDto) {
|
||||
return this.carreraService.create(createCarreraDto);
|
||||
}
|
||||
|
||||
@Get()
|
||||
findAll() {
|
||||
return this.carreraService.findAll();
|
||||
}
|
||||
|
||||
@Get(':id')
|
||||
findOne(@Param('id') id: string) {
|
||||
return this.carreraService.findOne(+id);
|
||||
}
|
||||
|
||||
@Patch(':id')
|
||||
update(@Param('id') id: string, @Body() updateCarreraDto: UpdateCarreraDto) {
|
||||
return this.carreraService.update(+id, updateCarreraDto);
|
||||
}
|
||||
|
||||
@Delete(':id')
|
||||
remove(@Param('id') id: string) {
|
||||
return this.carreraService.remove(+id);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { CarreraService } from './carrera.service';
|
||||
import { CarreraController } from './carrera.controller';
|
||||
|
||||
@Module({
|
||||
controllers: [CarreraController],
|
||||
providers: [CarreraService],
|
||||
})
|
||||
export class CarreraModule {}
|
||||
@@ -0,0 +1,26 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { CreateCarreraDto } from './dto/create-carrera.dto';
|
||||
import { UpdateCarreraDto } from './dto/update-carrera.dto';
|
||||
|
||||
@Injectable()
|
||||
export class CarreraService {
|
||||
create(createCarreraDto: CreateCarreraDto) {
|
||||
return 'This action adds a new carrera';
|
||||
}
|
||||
|
||||
findAll() {
|
||||
return `This action returns all carrera`;
|
||||
}
|
||||
|
||||
findOne(id: number) {
|
||||
return `This action returns a #${id} carrera`;
|
||||
}
|
||||
|
||||
update(id: number, updateCarreraDto: UpdateCarreraDto) {
|
||||
return `This action updates a #${id} carrera`;
|
||||
}
|
||||
|
||||
remove(id: number) {
|
||||
return `This action removes a #${id} carrera`;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
export class CreateCarreraDto {}
|
||||
@@ -0,0 +1,4 @@
|
||||
import { PartialType } from '@nestjs/mapped-types';
|
||||
import { CreateCarreraDto } from './create-carrera.dto';
|
||||
|
||||
export class UpdateCarreraDto extends PartialType(CreateCarreraDto) {}
|
||||
@@ -0,0 +1,19 @@
|
||||
import { CasoEspecial } from "src/caso-especial/entities/caso-especial.entity";
|
||||
import { Servicio } from "src/servicio/entities/servicio.entity";
|
||||
import { Column, Entity, ManyToMany, OneToMany, PrimaryGeneratedColumn } from "typeorm";
|
||||
|
||||
|
||||
@Entity('carrera')
|
||||
export class Carrera {
|
||||
@PrimaryGeneratedColumn()
|
||||
idCarrera:number;
|
||||
|
||||
@Column({type: 'varchar', length: 50, nullable: false})
|
||||
carrera:string;
|
||||
|
||||
@OneToMany(()=>Servicio, (servicio)=>servicio.carrera)
|
||||
servicio:Servicio[];
|
||||
|
||||
@OneToMany(()=>CasoEspecial,(casoEspecial)=>casoEspecial.carrera)
|
||||
casoEspecial:CasoEspecial[];
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
import { Controller, Get, Post, Body, Patch, Param, Delete } from '@nestjs/common';
|
||||
import { CasoEspecialService } from './caso-especial.service';
|
||||
import { CreateCasoEspecialDto } from './dto/create-caso-especial.dto';
|
||||
import { UpdateCasoEspecialDto } from './dto/update-caso-especial.dto';
|
||||
|
||||
@Controller('caso-especial')
|
||||
export class CasoEspecialController {
|
||||
constructor(private readonly casoEspecialService: CasoEspecialService) {}
|
||||
|
||||
@Post()
|
||||
create(@Body() createCasoEspecialDto: CreateCasoEspecialDto) {
|
||||
return this.casoEspecialService.create(createCasoEspecialDto);
|
||||
}
|
||||
|
||||
@Get()
|
||||
findAll() {
|
||||
return this.casoEspecialService.findAll();
|
||||
}
|
||||
|
||||
@Get(':id')
|
||||
findOne(@Param('id') id: string) {
|
||||
return this.casoEspecialService.findOne(+id);
|
||||
}
|
||||
|
||||
@Patch(':id')
|
||||
update(@Param('id') id: string, @Body() updateCasoEspecialDto: UpdateCasoEspecialDto) {
|
||||
return this.casoEspecialService.update(+id, updateCasoEspecialDto);
|
||||
}
|
||||
|
||||
@Delete(':id')
|
||||
remove(@Param('id') id: string) {
|
||||
return this.casoEspecialService.remove(+id);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { CasoEspecialService } from './caso-especial.service';
|
||||
import { CasoEspecialController } from './caso-especial.controller';
|
||||
|
||||
@Module({
|
||||
controllers: [CasoEspecialController],
|
||||
providers: [CasoEspecialService],
|
||||
})
|
||||
export class CasoEspecialModule {}
|
||||
@@ -0,0 +1,26 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { CreateCasoEspecialDto } from './dto/create-caso-especial.dto';
|
||||
import { UpdateCasoEspecialDto } from './dto/update-caso-especial.dto';
|
||||
|
||||
@Injectable()
|
||||
export class CasoEspecialService {
|
||||
create(createCasoEspecialDto: CreateCasoEspecialDto) {
|
||||
return 'This action adds a new casoEspecial';
|
||||
}
|
||||
|
||||
findAll() {
|
||||
return `This action returns all casoEspecial`;
|
||||
}
|
||||
|
||||
findOne(id: number) {
|
||||
return `This action returns a #${id} casoEspecial`;
|
||||
}
|
||||
|
||||
update(id: number, updateCasoEspecialDto: UpdateCasoEspecialDto) {
|
||||
return `This action updates a #${id} casoEspecial`;
|
||||
}
|
||||
|
||||
remove(id: number) {
|
||||
return `This action removes a #${id} casoEspecial`;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
export class CreateCasoEspecialDto {}
|
||||
@@ -0,0 +1,4 @@
|
||||
import { PartialType } from '@nestjs/mapped-types';
|
||||
import { CreateCasoEspecialDto } from './create-caso-especial.dto';
|
||||
|
||||
export class UpdateCasoEspecialDto extends PartialType(CreateCasoEspecialDto) {}
|
||||
@@ -0,0 +1,57 @@
|
||||
import { Carrera } from "src/carrera/entities/carrera.entity";
|
||||
import { Status } from "src/status/entities/status.entity";
|
||||
import { Usuario } from "src/usuario/entities/usuario.entity";
|
||||
import { Column, Entity, ManyToMany, PrimaryGeneratedColumn } from "typeorm";
|
||||
|
||||
@Entity('caso_especial')
|
||||
export class CasoEspecial {
|
||||
@PrimaryGeneratedColumn()
|
||||
idCasoEspecial: number;
|
||||
|
||||
@Column({ type: 'varchar', length: 3 })
|
||||
creditos: string;
|
||||
|
||||
@Column({ type: 'varchar', length: 60 })
|
||||
correo: string;
|
||||
|
||||
@Column({ type: 'varchar', length: 15 })
|
||||
telefono: string;
|
||||
|
||||
@Column({ type: 'varchar', length: 200, nullable: true, default: null })
|
||||
institucion: string | null;
|
||||
|
||||
@Column({ type: 'varchar', length: 200, nullable: true, default: null })
|
||||
dependencia: string | null;
|
||||
|
||||
@Column({ type: 'varchar', length: 1, nullable: true, default: null })
|
||||
motivo: string | null;
|
||||
|
||||
@Column({ type: 'varchar', length: 200 })
|
||||
direccion: string;
|
||||
|
||||
@Column({ type: 'timestamp' })
|
||||
fechaInicio: Date;
|
||||
|
||||
@Column({ type: 'timestamp' })
|
||||
fechaFin: Date;
|
||||
|
||||
@Column({ type: 'timestamp' })
|
||||
fechaNacimiento: Date;
|
||||
|
||||
@Column({ type: 'varchar', length: 60 })
|
||||
carpeta: string;
|
||||
|
||||
@Column({ type: 'varchar', length: 60 })
|
||||
archivoZip: string;
|
||||
|
||||
@ManyToMany(()=>Usuario, (usuario)=>usuario.casoEspecial)
|
||||
usuario:Usuario;
|
||||
|
||||
@ManyToMany(()=>Carrera, (carrera)=>carrera.casoEspecial)
|
||||
carrera:Carrera;
|
||||
|
||||
@ManyToMany(()=>Status, (status)=>status.casoEspecial)
|
||||
status:Status;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
import { Controller, Get, Post, Body, Patch, Param, Delete } from '@nestjs/common';
|
||||
import { CuestionarioAlumnoService } from './cuestionario-alumno.service';
|
||||
import { CreateCuestionarioAlumnoDto } from './dto/create-cuestionario-alumno.dto';
|
||||
import { UpdateCuestionarioAlumnoDto } from './dto/update-cuestionario-alumno.dto';
|
||||
|
||||
@Controller('cuestionario-alumno')
|
||||
export class CuestionarioAlumnoController {
|
||||
constructor(private readonly cuestionarioAlumnoService: CuestionarioAlumnoService) {}
|
||||
|
||||
@Post()
|
||||
create(@Body() createCuestionarioAlumnoDto: CreateCuestionarioAlumnoDto) {
|
||||
return this.cuestionarioAlumnoService.create(createCuestionarioAlumnoDto);
|
||||
}
|
||||
|
||||
@Get()
|
||||
findAll() {
|
||||
return this.cuestionarioAlumnoService.findAll();
|
||||
}
|
||||
|
||||
@Get(':id')
|
||||
findOne(@Param('id') id: string) {
|
||||
return this.cuestionarioAlumnoService.findOne(+id);
|
||||
}
|
||||
|
||||
@Patch(':id')
|
||||
update(@Param('id') id: string, @Body() updateCuestionarioAlumnoDto: UpdateCuestionarioAlumnoDto) {
|
||||
return this.cuestionarioAlumnoService.update(+id, updateCuestionarioAlumnoDto);
|
||||
}
|
||||
|
||||
@Delete(':id')
|
||||
remove(@Param('id') id: string) {
|
||||
return this.cuestionarioAlumnoService.remove(+id);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { CuestionarioAlumnoService } from './cuestionario-alumno.service';
|
||||
import { CuestionarioAlumnoController } from './cuestionario-alumno.controller';
|
||||
|
||||
@Module({
|
||||
controllers: [CuestionarioAlumnoController],
|
||||
providers: [CuestionarioAlumnoService],
|
||||
})
|
||||
export class CuestionarioAlumnoModule {}
|
||||
@@ -0,0 +1,26 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { CreateCuestionarioAlumnoDto } from './dto/create-cuestionario-alumno.dto';
|
||||
import { UpdateCuestionarioAlumnoDto } from './dto/update-cuestionario-alumno.dto';
|
||||
|
||||
@Injectable()
|
||||
export class CuestionarioAlumnoService {
|
||||
create(createCuestionarioAlumnoDto: CreateCuestionarioAlumnoDto) {
|
||||
return 'This action adds a new cuestionarioAlumno';
|
||||
}
|
||||
|
||||
leer() {
|
||||
return `This action returns all cuestionarioAlumno`;
|
||||
}
|
||||
|
||||
findOne(id: number) {
|
||||
return `This action returns a #${id} cuestionarioAlumno`;
|
||||
}
|
||||
|
||||
update(id: number, updateCuestionarioAlumnoDto: UpdateCuestionarioAlumnoDto) {
|
||||
return `This action updates a #${id} cuestionarioAlumno`;
|
||||
}
|
||||
|
||||
remove(id: number) {
|
||||
return `This action removes a #${id} cuestionarioAlumno`;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
export class CreateCuestionarioAlumnoDto {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
import { PartialType } from '@nestjs/mapped-types';
|
||||
import { CreateCuestionarioAlumnoDto } from './create-cuestionario-alumno.dto';
|
||||
|
||||
export class UpdateCuestionarioAlumnoDto extends PartialType(CreateCuestionarioAlumnoDto) {}
|
||||
@@ -0,0 +1,111 @@
|
||||
import { Servicio } from "src/servicio/entities/servicio.entity";
|
||||
import { Column, Entity, OneToMany, PrimaryGeneratedColumn } from "typeorm";
|
||||
|
||||
@Entity('cuestionario_alumno')
|
||||
export class CuestionarioAlumno {
|
||||
@PrimaryGeneratedColumn()
|
||||
idCuestionarioAlumno: number;
|
||||
|
||||
@Column({ type: 'varchar', length: 1 })
|
||||
sexo: string;
|
||||
|
||||
@Column({ type: 'varchar', length: 2 })
|
||||
edad: string;
|
||||
|
||||
@Column({ type: 'varchar', length: 100 })
|
||||
servicioMedico: string;
|
||||
|
||||
@Column()
|
||||
p1: boolean;
|
||||
|
||||
@Column()
|
||||
p2: boolean;
|
||||
|
||||
@Column({ type: 'varchar', length: 150 })
|
||||
p3: string;
|
||||
|
||||
@Column()
|
||||
p4: boolean;
|
||||
|
||||
@Column({ type: 'varchar', length: 7 })
|
||||
p5: string;
|
||||
|
||||
@Column()
|
||||
p6: boolean;
|
||||
|
||||
@Column()
|
||||
p7: boolean;
|
||||
|
||||
@Column({ type: 'varchar', length: 5 })
|
||||
p8: string;
|
||||
|
||||
@Column()
|
||||
p9: boolean;
|
||||
|
||||
@Column()
|
||||
p10: boolean;
|
||||
|
||||
@Column()
|
||||
p11: boolean;
|
||||
|
||||
@Column()
|
||||
p12: boolean;
|
||||
|
||||
@Column()
|
||||
p13: boolean;
|
||||
|
||||
@Column({ type: 'varchar', length: 7 })
|
||||
p14: string;
|
||||
|
||||
@Column({ type: 'varchar', length: 7 })
|
||||
p15: string;
|
||||
|
||||
@Column({ type: 'varchar', length: 2 })
|
||||
p16: string;
|
||||
|
||||
@Column({ type: 'varchar', length: 5 })
|
||||
p17: string;
|
||||
|
||||
@Column()
|
||||
p18: boolean;
|
||||
|
||||
@Column()
|
||||
p19: boolean;
|
||||
|
||||
@Column()
|
||||
p20: boolean;
|
||||
|
||||
@Column({ type: 'varchar', length: 9 })
|
||||
p21: string;
|
||||
|
||||
@Column({ type: 'varchar', length: 23 })
|
||||
p22: string;
|
||||
|
||||
@Column({ type: 'varchar', length: 8 })
|
||||
p23: string;
|
||||
|
||||
@Column({ type: 'varchar', length: 8 })
|
||||
p24: string;
|
||||
|
||||
@Column()
|
||||
p25: boolean;
|
||||
|
||||
@Column()
|
||||
p26: boolean;
|
||||
|
||||
@Column({ type: 'varchar', length: 400 })
|
||||
p27: string;
|
||||
|
||||
@Column({ type: 'varchar', length: 1 })
|
||||
p28: string;
|
||||
|
||||
@Column({ type: 'varchar', length: 1 })
|
||||
p29: string;
|
||||
|
||||
@Column({ type: 'varchar', length: 400 })
|
||||
p30: string;
|
||||
|
||||
@OneToMany(()=>Servicio,(servicio)=>servicio.cuestionarioAlumno2)
|
||||
servicio:Servicio[];
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
import { Controller, Get, Post, Body, Patch, Param, Delete } from '@nestjs/common';
|
||||
import { CuestionarioAlumno2Service } from './cuestionario-alumno2.service';
|
||||
import { CreateCuestionarioAlumno2Dto } from './dto/create-cuestionario-alumno2.dto';
|
||||
import { UpdateCuestionarioAlumno2Dto } from './dto/update-cuestionario-alumno2.dto';
|
||||
|
||||
@Controller('cuestionario-alumno2')
|
||||
export class CuestionarioAlumno2Controller {
|
||||
constructor(private readonly cuestionarioAlumno2Service: CuestionarioAlumno2Service) {}
|
||||
|
||||
@Post()
|
||||
create(@Body() createCuestionarioAlumno2Dto: CreateCuestionarioAlumno2Dto) {
|
||||
return this.cuestionarioAlumno2Service.create(createCuestionarioAlumno2Dto);
|
||||
}
|
||||
|
||||
@Get()
|
||||
findAll() {
|
||||
return this.cuestionarioAlumno2Service.findAll();
|
||||
}
|
||||
|
||||
@Get(':id')
|
||||
findOne(@Param('id') id: string) {
|
||||
return this.cuestionarioAlumno2Service.findOne(+id);
|
||||
}
|
||||
|
||||
@Patch(':id')
|
||||
update(@Param('id') id: string, @Body() updateCuestionarioAlumno2Dto: UpdateCuestionarioAlumno2Dto) {
|
||||
return this.cuestionarioAlumno2Service.update(+id, updateCuestionarioAlumno2Dto);
|
||||
}
|
||||
|
||||
@Delete(':id')
|
||||
remove(@Param('id') id: string) {
|
||||
return this.cuestionarioAlumno2Service.remove(+id);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { CuestionarioAlumno2Service } from './cuestionario-alumno2.service';
|
||||
import { CuestionarioAlumno2Controller } from './cuestionario-alumno2.controller';
|
||||
|
||||
@Module({
|
||||
controllers: [CuestionarioAlumno2Controller],
|
||||
providers: [CuestionarioAlumno2Service],
|
||||
})
|
||||
export class CuestionarioAlumno2Module {}
|
||||
@@ -0,0 +1,119 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { CreateCuestionarioAlumno2Dto } from './dto/create-cuestionario-alumno2.dto';
|
||||
import { UpdateCuestionarioAlumno2Dto } from './dto/update-cuestionario-alumno2.dto';
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
import { Servicio } from 'src/servicio/entities/servicio.entity';
|
||||
import { IsNull, Not, Repository } from 'typeorm';
|
||||
import { CuestionarioAlumno } from 'src/cuestionario-alumno/entities/cuestionario-alumno.entity';
|
||||
import { CuestionarioAlumno2 } from './entities/cuestionario-alumno2.entity';
|
||||
import { messageByStatus } from 'src/messageByStatus';
|
||||
import { ArchivoService } from 'src/helpers/archivo.service';
|
||||
import { ValidacionService } from 'src/validaciones/validacion.service';
|
||||
const { convertArrayToCSV } = require('convert-array-to-csv');
|
||||
|
||||
|
||||
|
||||
@Injectable()
|
||||
export class CuestionarioAlumno2Service {
|
||||
constructor(
|
||||
@InjectRepository(Servicio)
|
||||
private servicioRepository:Repository<Servicio>,
|
||||
@InjectRepository(CuestionarioAlumno2)
|
||||
private cuestionarioAlumno2Repository:Repository<CuestionarioAlumno2>,
|
||||
@InjectRepository(CuestionarioAlumno)
|
||||
private cuestionarioAlumnoRepository:Repository<CuestionarioAlumno>,
|
||||
private validacionService:ValidacionService,
|
||||
private archivoService:ArchivoService,
|
||||
|
||||
|
||||
){}
|
||||
|
||||
async create(createCuestionarioAlumno2Dto: CreateCuestionarioAlumno2Dto) {
|
||||
|
||||
let idServicio=createCuestionarioAlumno2Dto.idServicio
|
||||
|
||||
let cuestionario2= await this.validacionService.validarCuestionarioAlumno2(createCuestionarioAlumno2Dto)
|
||||
|
||||
|
||||
let servicio = await this.servicioRepository.findOne({where:{idServicio}});
|
||||
if(!servicio){
|
||||
throw new Error('No existe este Servicio Social.');
|
||||
}
|
||||
|
||||
if(servicio.cuestionarioAlumno2.idCuestionarioAlumno2){
|
||||
throw new Error('Este Servicio Social ya cuenta con cuestionario de alumno');
|
||||
}
|
||||
|
||||
console.log('el servicio social si existe');
|
||||
|
||||
|
||||
console.log('antes de create ques2');
|
||||
|
||||
if (messageByStatus.hasOwnProperty(servicio.status.idStatus)){
|
||||
throw new Error(messageByStatus[servicio.status.idStatus]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
console.log("datos a registrar en la tabla cuestionarioAlumno2", { ...cuestionario2} );
|
||||
|
||||
let respuestasRegistradas = await this.cuestionarioAlumno2Repository.save( cuestionario2);
|
||||
console.log('despues de registrar cuestionario', respuestasRegistradas);
|
||||
|
||||
|
||||
console.log('agregar el id a la tabla servicio, esta validado en el front');
|
||||
|
||||
let resX= await this.servicioRepository.update(
|
||||
{idServicio},
|
||||
{cuestionarioAlumno2:respuestasRegistradas}
|
||||
)
|
||||
|
||||
return resX;
|
||||
}
|
||||
|
||||
async get(version:string, anio:string){
|
||||
const year = this.validacionService.validarNumero(anio, 'año', true, 4);
|
||||
const path = `server/uploads/${year}_cuestionario_alumno.csv`;
|
||||
|
||||
let data = [];
|
||||
|
||||
console.log(year);
|
||||
let temp
|
||||
|
||||
if(version == 'v1'){
|
||||
temp = this.cuestionarioAlumnoRepository.find({
|
||||
where: {
|
||||
idCuestionarioAlumno: Not(IsNull()),
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
if(version == 'v2'){
|
||||
temp = this.cuestionarioAlumno2Repository.find({
|
||||
where: {
|
||||
idCuestionarioAlumno2: Not(IsNull()),
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
if(!temp){
|
||||
throw new Error()
|
||||
}
|
||||
|
||||
data = temp.map(item => ({ ...item }));
|
||||
|
||||
await this.archivoService.eliminarArchivo(path).catch((err) => {
|
||||
console.log(err);
|
||||
});
|
||||
|
||||
return this.archivoService.crearArchivo(path, convertArrayToCSV(data));
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,188 @@
|
||||
import { IsNotEmpty, IsOptional, IsString, IsNumber } from 'class-validator';
|
||||
|
||||
|
||||
|
||||
export class CreateCuestionarioAlumno2Dto {
|
||||
|
||||
|
||||
@IsNumber()
|
||||
@IsNotEmpty()
|
||||
idServicio:number
|
||||
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
p1: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
p2: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
p4: string;
|
||||
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
p5?: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
p6: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
p7: string;
|
||||
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
p8?: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
p9: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
p3_1: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
p3_2: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
p3_3: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
p3_4: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
p10_1: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
p10_2: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
p10_3: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
p11_1: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
p11_2: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
p11_3: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
p11_4: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
p12_A_1: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
p12_A_2: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
p12_A_3: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
p12_A_4: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
p12_B_1: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
p12_B_2: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
p12_B_3: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
p12_B_4: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
p12_C_1: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
p12_C_2: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
p12_C_3: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
p12_C_4: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
p12_D_1: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
p12_D_2: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
p12_D_3: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
p12_D_4: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
p12_D_5: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
p13: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
p14: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
p15: string;
|
||||
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
p16: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
p17_1: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
p17_2: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
p17_3: string;
|
||||
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
p18: string;
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
import { PartialType } from '@nestjs/mapped-types';
|
||||
import { CreateCuestionarioAlumno2Dto } from './create-cuestionario-alumno2.dto';
|
||||
|
||||
export class UpdateCuestionarioAlumno2Dto extends PartialType(CreateCuestionarioAlumno2Dto) {}
|
||||
@@ -0,0 +1,145 @@
|
||||
import { Servicio } from "src/servicio/entities/servicio.entity";
|
||||
import { Column, Entity, OneToMany, PrimaryGeneratedColumn } from "typeorm";
|
||||
|
||||
@Entity('cuestionario_alumno_2')
|
||||
export class CuestionarioAlumno2 {
|
||||
|
||||
@PrimaryGeneratedColumn()
|
||||
idCuestionarioAlumno2: number;
|
||||
|
||||
@Column({ type: 'varchar', length: 100, nullable: false })
|
||||
p1: string;
|
||||
|
||||
@Column({ type: 'varchar', length: 50, nullable: false })
|
||||
p2: string;
|
||||
|
||||
@Column({ type: 'varchar', length: 5, nullable: false })
|
||||
p4: string;
|
||||
|
||||
@Column({ type: 'varchar', length: 50, nullable: true })
|
||||
p5: string;
|
||||
|
||||
@Column({ type: 'varchar', length: 5, nullable: false })
|
||||
p6: string;
|
||||
|
||||
@Column({ type: 'varchar', length: 5, nullable: false })
|
||||
p7: string;
|
||||
|
||||
@Column({ type: 'varchar', length: 50, nullable: true })
|
||||
p8: string;
|
||||
|
||||
@Column({ type: 'varchar', length: 5, nullable: false })
|
||||
p9: string;
|
||||
|
||||
@Column({ type: 'varchar', length: 5, nullable: false })
|
||||
p3_1: string;
|
||||
|
||||
@Column({ type: 'varchar', length: 5, nullable: false })
|
||||
p3_2: string;
|
||||
|
||||
@Column({ type: 'varchar', length: 5, nullable: false })
|
||||
p3_3: string;
|
||||
|
||||
@Column({ type: 'varchar', length: 5, nullable: false })
|
||||
p3_4: string;
|
||||
|
||||
@Column({ type: 'varchar', length: 5, nullable: false })
|
||||
p10_1: string;
|
||||
|
||||
@Column({ type: 'varchar', length: 5, nullable: false })
|
||||
p10_2: string;
|
||||
|
||||
@Column({ type: 'varchar', length: 5, nullable: false })
|
||||
p10_3: string;
|
||||
|
||||
@Column({ type: 'varchar', length: 20, nullable: false })
|
||||
p11_1: string;
|
||||
|
||||
@Column({ type: 'varchar', length: 20, nullable: false })
|
||||
p11_2: string;
|
||||
|
||||
@Column({ type: 'varchar', length: 20, nullable: false })
|
||||
p11_3: string;
|
||||
|
||||
@Column({ type: 'varchar', length: 20, nullable: false })
|
||||
p11_4: string;
|
||||
|
||||
@Column({ type: 'varchar', length: 20, nullable: false })
|
||||
p12_A_1: string;
|
||||
|
||||
@Column({ type: 'varchar', length: 20, nullable: false })
|
||||
p12_A_2: string;
|
||||
|
||||
@Column({ type: 'varchar', length: 20, nullable: false })
|
||||
p12_A_3: string;
|
||||
|
||||
@Column({ type: 'varchar', length: 20, nullable: false })
|
||||
p12_A_4: string;
|
||||
|
||||
@Column({ type: 'varchar', length: 20, nullable: false })
|
||||
p12_B_1: string;
|
||||
|
||||
@Column({ type: 'varchar', length: 20, nullable: false })
|
||||
p12_B_2: string;
|
||||
|
||||
@Column({ type: 'varchar', length: 20, nullable: false })
|
||||
p12_B_3: string;
|
||||
|
||||
@Column({ type: 'varchar', length: 20, nullable: false })
|
||||
p12_B_4: string;
|
||||
|
||||
@Column({ type: 'varchar', length: 20, nullable: false })
|
||||
p12_C_1: string;
|
||||
|
||||
@Column({ type: 'varchar', length: 20, nullable: false })
|
||||
p12_C_2: string;
|
||||
|
||||
@Column({ type: 'varchar', length: 20, nullable: false })
|
||||
p12_C_3: string;
|
||||
|
||||
@Column({ type: 'varchar', length: 20, nullable: false })
|
||||
p12_C_4: string;
|
||||
|
||||
@Column({ type: 'varchar', length: 20, nullable: false })
|
||||
p12_D_1: string;
|
||||
|
||||
@Column({ type: 'varchar', length: 20, nullable: false })
|
||||
p12_D_2: string;
|
||||
|
||||
@Column({ type: 'varchar', length: 20, nullable: false })
|
||||
p12_D_3: string;
|
||||
|
||||
@Column({ type: 'varchar', length: 20, nullable: false })
|
||||
p12_D_4: string;
|
||||
|
||||
@Column({ type: 'varchar', length: 20, nullable: false })
|
||||
p12_D_5: string;
|
||||
|
||||
@Column({ type: 'varchar', length: 100, nullable: false })
|
||||
p13: string;
|
||||
|
||||
@Column({ type: 'varchar', length: 100, nullable: false })
|
||||
p14: string;
|
||||
|
||||
@Column({ type: 'varchar', length: 5, nullable: false })
|
||||
p15: string;
|
||||
|
||||
@Column({ type: 'varchar', length: 50, nullable: true })
|
||||
p16: string;
|
||||
|
||||
@Column({ type: 'varchar', length: 5, nullable: false })
|
||||
p17_1: string;
|
||||
|
||||
@Column({ type: 'varchar', length: 5, nullable: false })
|
||||
p17_2: string;
|
||||
|
||||
@Column({ type: 'varchar', length: 5, nullable: false })
|
||||
p17_3: string;
|
||||
|
||||
@Column({ type: 'varchar', length: 50, nullable: true })
|
||||
p18: string;
|
||||
|
||||
@OneToMany(()=>Servicio,(servicio)=>servicio.cuestionarioAlumno2)
|
||||
servicio:Servicio[];
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
import { Controller, Get, Post, Body, Patch, Param, Delete } from '@nestjs/common';
|
||||
import { CuestionarioProgramaService } from './cuestionario-programa.service';
|
||||
import { CreateCuestionarioProgramaDto } from './dto/create-cuestionario-programa.dto';
|
||||
import { UpdateCuestionarioProgramaDto } from './dto/update-cuestionario-programa.dto';
|
||||
|
||||
@Controller('cuestionario-programa')
|
||||
export class CuestionarioProgramaController {
|
||||
constructor(private readonly cuestionarioProgramaService: CuestionarioProgramaService) {}
|
||||
|
||||
@Post()
|
||||
create(@Body() createCuestionarioProgramaDto: CreateCuestionarioProgramaDto) {
|
||||
return this.cuestionarioProgramaService.create(createCuestionarioProgramaDto);
|
||||
}
|
||||
|
||||
@Get()
|
||||
findAll() {
|
||||
return this.cuestionarioProgramaService.findAll();
|
||||
}
|
||||
|
||||
@Get(':id')
|
||||
findOne(@Param('id') id: string) {
|
||||
return this.cuestionarioProgramaService.findOne(+id);
|
||||
}
|
||||
|
||||
@Patch(':id')
|
||||
update(@Param('id') id: string, @Body() updateCuestionarioProgramaDto: UpdateCuestionarioProgramaDto) {
|
||||
return this.cuestionarioProgramaService.update(+id, updateCuestionarioProgramaDto);
|
||||
}
|
||||
|
||||
@Delete(':id')
|
||||
remove(@Param('id') id: string) {
|
||||
return this.cuestionarioProgramaService.remove(+id);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { CuestionarioProgramaService } from './cuestionario-programa.service';
|
||||
import { CuestionarioProgramaController } from './cuestionario-programa.controller';
|
||||
|
||||
@Module({
|
||||
controllers: [CuestionarioProgramaController],
|
||||
providers: [CuestionarioProgramaService],
|
||||
})
|
||||
export class CuestionarioProgramaModule {}
|
||||
@@ -0,0 +1,26 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { CreateCuestionarioProgramaDto } from './dto/create-cuestionario-programa.dto';
|
||||
import { UpdateCuestionarioProgramaDto } from './dto/update-cuestionario-programa.dto';
|
||||
|
||||
@Injectable()
|
||||
export class CuestionarioProgramaService {
|
||||
create(createCuestionarioProgramaDto: CreateCuestionarioProgramaDto) {
|
||||
return 'This action adds a new cuestionarioPrograma';
|
||||
}
|
||||
|
||||
findAll() {
|
||||
return `This action returns all cuestionarioPrograma`;
|
||||
}
|
||||
|
||||
findOne(id: number) {
|
||||
return `This action returns a #${id} cuestionarioPrograma`;
|
||||
}
|
||||
|
||||
update(id: number, updateCuestionarioProgramaDto: UpdateCuestionarioProgramaDto) {
|
||||
return `This action updates a #${id} cuestionarioPrograma`;
|
||||
}
|
||||
|
||||
remove(id: number) {
|
||||
return `This action removes a #${id} cuestionarioPrograma`;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
export class CreateCuestionarioProgramaDto {}
|
||||
@@ -0,0 +1,4 @@
|
||||
import { PartialType } from '@nestjs/mapped-types';
|
||||
import { CreateCuestionarioProgramaDto } from './create-cuestionario-programa.dto';
|
||||
|
||||
export class UpdateCuestionarioProgramaDto extends PartialType(CreateCuestionarioProgramaDto) {}
|
||||
@@ -0,0 +1,35 @@
|
||||
import { Servicio } from "src/servicio/entities/servicio.entity";
|
||||
import { Column, Entity, OneToMany, PrimaryGeneratedColumn } from "typeorm";
|
||||
|
||||
@Entity('cuestionario_programa')
|
||||
export class CuestionarioPrograma {
|
||||
@PrimaryGeneratedColumn()
|
||||
idCuestionarioPrograma: number;
|
||||
|
||||
@Column({ type: 'varchar', length: 400, nullable: false })
|
||||
actividad1: string;
|
||||
|
||||
@Column({ type: 'varchar', length: 400, nullable: false })
|
||||
actividad2: string;
|
||||
|
||||
@Column({ type: 'varchar', length: 400, nullable: false })
|
||||
actividad3: string;
|
||||
|
||||
@Column({ type: 'varchar', length: 400, nullable: false })
|
||||
actividad4: string;
|
||||
|
||||
@Column({ type: 'varchar', length: 400, nullable: false })
|
||||
actividad5: string;
|
||||
|
||||
@Column({ type: 'varchar', length: 9, nullable: false })
|
||||
retroalimentacion: string;
|
||||
|
||||
@Column({ type: 'varchar', length: 800, nullable: false })
|
||||
p6: string;
|
||||
|
||||
@Column({ type: 'varchar', length: 800, nullable: false })
|
||||
p7: string;
|
||||
|
||||
@OneToMany(()=>Servicio,(servicio)=>servicio.cuestionarioPrograma)
|
||||
servicio:Servicio[];
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
import { Controller, Get, Post, Body, Patch, Param, Delete } from '@nestjs/common';
|
||||
import { CuestionarioPrograma2Service } from './cuestionario-programa2.service';
|
||||
import { CreateCuestionarioPrograma2Dto } from './dto/create-cuestionario-programa2.dto';
|
||||
import { UpdateCuestionarioPrograma2Dto } from './dto/update-cuestionario-programa2.dto';
|
||||
|
||||
@Controller('cuestionario-programa2')
|
||||
export class CuestionarioPrograma2Controller {
|
||||
constructor(private readonly cuestionarioPrograma2Service: CuestionarioPrograma2Service) {}
|
||||
|
||||
@Post()
|
||||
create(@Body() createCuestionarioPrograma2Dto: CreateCuestionarioPrograma2Dto) {
|
||||
return this.cuestionarioPrograma2Service.create(createCuestionarioPrograma2Dto);
|
||||
}
|
||||
|
||||
@Get()
|
||||
findAll() {
|
||||
return this.cuestionarioPrograma2Service.findAll();
|
||||
}
|
||||
|
||||
@Get(':id')
|
||||
findOne(@Param('id') id: string) {
|
||||
return this.cuestionarioPrograma2Service.findOne(+id);
|
||||
}
|
||||
|
||||
@Patch(':id')
|
||||
update(@Param('id') id: string, @Body() updateCuestionarioPrograma2Dto: UpdateCuestionarioPrograma2Dto) {
|
||||
return this.cuestionarioPrograma2Service.update(+id, updateCuestionarioPrograma2Dto);
|
||||
}
|
||||
|
||||
@Delete(':id')
|
||||
remove(@Param('id') id: string) {
|
||||
return this.cuestionarioPrograma2Service.remove(+id);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { CuestionarioPrograma2Service } from './cuestionario-programa2.service';
|
||||
import { CuestionarioPrograma2Controller } from './cuestionario-programa2.controller';
|
||||
|
||||
@Module({
|
||||
controllers: [CuestionarioPrograma2Controller],
|
||||
providers: [CuestionarioPrograma2Service],
|
||||
})
|
||||
export class CuestionarioPrograma2Module {}
|
||||
@@ -0,0 +1,26 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { CreateCuestionarioPrograma2Dto } from './dto/create-cuestionario-programa2.dto';
|
||||
import { UpdateCuestionarioPrograma2Dto } from './dto/update-cuestionario-programa2.dto';
|
||||
|
||||
@Injectable()
|
||||
export class CuestionarioPrograma2Service {
|
||||
create(createCuestionarioPrograma2Dto: CreateCuestionarioPrograma2Dto) {
|
||||
return 'This action adds a new cuestionarioPrograma2';
|
||||
}
|
||||
|
||||
findAll() {
|
||||
return `This action returns all cuestionarioPrograma2`;
|
||||
}
|
||||
|
||||
findOne(id: number) {
|
||||
return `This action returns a #${id} cuestionarioPrograma2`;
|
||||
}
|
||||
|
||||
update(id: number, updateCuestionarioPrograma2Dto: UpdateCuestionarioPrograma2Dto) {
|
||||
return `This action updates a #${id} cuestionarioPrograma2`;
|
||||
}
|
||||
|
||||
remove(id: number) {
|
||||
return `This action removes a #${id} cuestionarioPrograma2`;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
export class CreateCuestionarioPrograma2Dto {}
|
||||
@@ -0,0 +1,4 @@
|
||||
import { PartialType } from '@nestjs/mapped-types';
|
||||
import { CreateCuestionarioPrograma2Dto } from './create-cuestionario-programa2.dto';
|
||||
|
||||
export class UpdateCuestionarioPrograma2Dto extends PartialType(CreateCuestionarioPrograma2Dto) {}
|
||||
@@ -0,0 +1,90 @@
|
||||
import { Servicio } from "src/servicio/entities/servicio.entity";
|
||||
import { Column, Entity, OneToMany, PrimaryGeneratedColumn } from "typeorm";
|
||||
|
||||
@Entity('cuestionario_programa_2')
|
||||
export class CuestionarioPrograma2 {
|
||||
@PrimaryGeneratedColumn()
|
||||
idCuestionarioPrograma2: number;
|
||||
|
||||
// Sección p3_A_*
|
||||
@Column({ type: 'varchar', length: 50, nullable: true })
|
||||
p3_A_1: string;
|
||||
|
||||
@Column({ type: 'varchar', length: 50, nullable: true })
|
||||
p3_A_2: string;
|
||||
|
||||
@Column({ type: 'varchar', length: 50, nullable: true })
|
||||
p3_A_3: string;
|
||||
|
||||
@Column({ type: 'varchar', length: 50, nullable: true })
|
||||
p3_A_4: string;
|
||||
|
||||
// Sección p3_B_*
|
||||
@Column({ type: 'varchar', length: 50, nullable: true })
|
||||
p3_B_1: string;
|
||||
|
||||
@Column({ type: 'varchar', length: 50, nullable: true })
|
||||
p3_B_2: string;
|
||||
|
||||
@Column({ type: 'varchar', length: 50, nullable: true })
|
||||
p3_B_3: string;
|
||||
|
||||
@Column({ type: 'varchar', length: 50, nullable: true })
|
||||
p3_B_4: string;
|
||||
|
||||
// Sección p3_C_*
|
||||
@Column({ type: 'varchar', length: 50, nullable: true })
|
||||
p3_C_1: string;
|
||||
|
||||
@Column({ type: 'varchar', length: 50, nullable: true })
|
||||
p3_C_2: string;
|
||||
|
||||
@Column({ type: 'varchar', length: 50, nullable: true })
|
||||
p3_C_3: string;
|
||||
|
||||
@Column({ type: 'varchar', length: 50, nullable: true })
|
||||
p3_C_4: string;
|
||||
|
||||
@Column({ type: 'varchar', length: 50, nullable: true })
|
||||
p3_C_5: string;
|
||||
|
||||
// Sección p3_D_*
|
||||
@Column({ type: 'varchar', length: 50, nullable: true })
|
||||
p3_D_1: string;
|
||||
|
||||
@Column({ type: 'varchar', length: 50, nullable: true })
|
||||
p3_D_2: string;
|
||||
|
||||
@Column({ type: 'varchar', length: 50, nullable: true })
|
||||
p3_D_3: string;
|
||||
|
||||
@Column({ type: 'varchar', length: 50, nullable: true })
|
||||
p3_D_4: string;
|
||||
|
||||
@Column({ type: 'varchar', length: 50, nullable: true })
|
||||
p3_D_5: string;
|
||||
|
||||
// Sección p3_E_*
|
||||
@Column({ type: 'varchar', length: 50, nullable: true })
|
||||
p3_E_1: string;
|
||||
|
||||
// p1, p2, p4, p5, p6
|
||||
@Column({ type: 'varchar', length: 100, nullable: true })
|
||||
p1: string;
|
||||
|
||||
@Column({ type: 'varchar', length: 50, nullable: true })
|
||||
p2: string;
|
||||
|
||||
@Column({ type: 'varchar', length: 100, nullable: true })
|
||||
p4: string;
|
||||
|
||||
@Column({ type: 'varchar', length: 5, nullable: true })
|
||||
p5: string;
|
||||
|
||||
@Column({ type: 'varchar', length: 100, nullable: true })
|
||||
p6: string;
|
||||
|
||||
@OneToMany(()=>Servicio,(servicio)=>servicio.cuestionarioAlumno2)
|
||||
servicio:Servicio[];
|
||||
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
// src/drive/drive.module.ts
|
||||
import { Module } from '@nestjs/common';
|
||||
import { DriveService } from './drive.service';
|
||||
|
||||
@Module({
|
||||
providers: [DriveService],
|
||||
exports: [DriveService],
|
||||
})
|
||||
export class DriveModule {}
|
||||
@@ -0,0 +1,172 @@
|
||||
// src/drive/drive.service.ts
|
||||
import { Injectable, InternalServerErrorException } from '@nestjs/common';
|
||||
import { google } from 'googleapis';
|
||||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
import { error } from 'console';
|
||||
|
||||
@Injectable()
|
||||
export class DriveService {
|
||||
private SCOPES = ['https://www.googleapis.com/auth/drive'];
|
||||
|
||||
private loadCredentials() {
|
||||
try {
|
||||
const credenciales = JSON.parse(
|
||||
fs.readFileSync(path.resolve('./cred.json'), 'utf8'),
|
||||
);
|
||||
credenciales.private_key = credenciales.private_key.replace(/\\n/g, '\n');
|
||||
return new google.auth.JWT(
|
||||
credenciales.client_email,
|
||||
undefined,
|
||||
credenciales.private_key,
|
||||
this.SCOPES,
|
||||
);
|
||||
} catch (err) {
|
||||
console.error('❌ Error cargando credenciales:', err);
|
||||
throw new InternalServerErrorException('Error al cargar credenciales');
|
||||
}
|
||||
}
|
||||
|
||||
async list(pageToken = '') {
|
||||
const authClient = await this.loadCredentials();
|
||||
const drive = google.drive({ version: 'v3', auth: authClient });
|
||||
|
||||
try {
|
||||
const res = await drive.files.list({
|
||||
corpora: 'user',
|
||||
supportsTeamDrives: true,
|
||||
includeTeamDriveItems: true,
|
||||
spaces: 'drive',
|
||||
pageSize: 1000,
|
||||
pageToken,
|
||||
orderBy: 'name',
|
||||
});
|
||||
return res.data;
|
||||
} catch (err) {
|
||||
throw new InternalServerErrorException(
|
||||
'Error al listar archivos: ' + err.message,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
async deleteFile(fileId: string) {
|
||||
if (fileId === process.env.CARPETA) {
|
||||
throw new Error('No se puede eliminar este archivo/carpeta.');
|
||||
}
|
||||
const authClient = await this.loadCredentials();
|
||||
const drive = google.drive({ version: 'v3', auth: authClient });
|
||||
|
||||
try {
|
||||
return await drive.files.delete({ fileId });
|
||||
} catch (err) {
|
||||
throw new InternalServerErrorException(
|
||||
'Error al eliminar archivo: ' + err.message,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
async uploadFile(filePath: string, name: string, mimeType: string, parent: string) {
|
||||
const authClient = await this.loadCredentials();
|
||||
const drive = google.drive({ version: 'v3', auth: authClient });
|
||||
|
||||
const requestBody = {
|
||||
name,
|
||||
parents: [parent],
|
||||
};
|
||||
const media = {
|
||||
mimeType,
|
||||
body: fs.createReadStream(filePath),
|
||||
};
|
||||
|
||||
try {
|
||||
const res = await drive.files.create({
|
||||
requestBody,
|
||||
media,
|
||||
fields: 'id',
|
||||
});
|
||||
fs.unlinkSync(filePath);
|
||||
return res.data.id;
|
||||
} catch (err) {
|
||||
throw new InternalServerErrorException(
|
||||
'Error al subir archivo: ' + err.message,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
async mkDir(name: string): Promise<string> {
|
||||
const authClient = await this.loadCredentials();
|
||||
const drive = google.drive({ version: 'v3', auth: authClient });
|
||||
|
||||
|
||||
if(!name){
|
||||
throw new Error()
|
||||
}
|
||||
if(!process.env.CARPETA){
|
||||
throw new Error()
|
||||
}
|
||||
|
||||
const requestBody = {
|
||||
name,
|
||||
mimeType: 'application/vnd.google-apps.folder',
|
||||
parents: [process.env.CARPETA],
|
||||
};
|
||||
|
||||
|
||||
try {
|
||||
const res = await drive.files.create({
|
||||
requestBody,
|
||||
fields: 'id',
|
||||
});
|
||||
|
||||
if(!res.data.id){
|
||||
throw new Error()
|
||||
}
|
||||
|
||||
return res.data.id;
|
||||
|
||||
} catch (err) {
|
||||
throw new InternalServerErrorException(
|
||||
'Error al crear carpeta: ' + err.message,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
async update(fileId: string, addParents: string, removeParents: string) {
|
||||
const authClient = await this.loadCredentials();
|
||||
const drive = google.drive({ version: 'v3', auth: authClient });
|
||||
|
||||
try {
|
||||
const res = await drive.files.update({
|
||||
fileId,
|
||||
addParents,
|
||||
removeParents,
|
||||
});
|
||||
return res.data;
|
||||
} catch (err) {
|
||||
throw new InternalServerErrorException(
|
||||
'Error al actualizar archivo: ' + err.message,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
async folder(numeroCuenta: string) {
|
||||
let pageToken = '';
|
||||
do {
|
||||
const res = await this.list(pageToken);
|
||||
if(!res.files){
|
||||
throw new Error()
|
||||
}
|
||||
for (const file of res.files) {
|
||||
if (
|
||||
file.name === numeroCuenta &&
|
||||
file.mimeType === 'application/vnd.google-apps.folder'
|
||||
) {
|
||||
return file.id;
|
||||
}
|
||||
}
|
||||
pageToken = res.nextPageToken || '';
|
||||
|
||||
} while (pageToken);
|
||||
return this.mkDir(numeroCuenta);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import * as fs from 'fs';
|
||||
import * as moment from 'moment';
|
||||
|
||||
@Injectable()
|
||||
export class ArchivoService {
|
||||
crearDDMMAAAA(date: any): string {
|
||||
const fechaMoment = moment(date);
|
||||
let ddmmaaaa = '';
|
||||
|
||||
if (fechaMoment.isValid()) {
|
||||
ddmmaaaa = `${fechaMoment.date()}/${fechaMoment.month() + 1}/${fechaMoment.year()}`;
|
||||
}
|
||||
|
||||
return ddmmaaaa;
|
||||
}
|
||||
|
||||
eliminarArchivo(path: string): Promise<{ message: string }> {
|
||||
return new Promise((resolve, reject) => {
|
||||
fs.unlink(path, (err) => {
|
||||
if (err) {
|
||||
reject(err);
|
||||
} else {
|
||||
resolve({ message: 'Se eliminó el archivo correctamente.' });
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
crearArchivo(path: string, texto: string): Promise<{ message: string }> {
|
||||
return new Promise((resolve, reject) => {
|
||||
fs.appendFile(path, texto, (err) => {
|
||||
if (err) {
|
||||
reject(err);
|
||||
} else {
|
||||
resolve({ message: 'Se creó el archivo correctamente.' });
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,10 @@ import { AppModule } from './app.module';
|
||||
|
||||
async function bootstrap() {
|
||||
const app = await NestFactory.create(AppModule);
|
||||
|
||||
|
||||
app.enableCors();
|
||||
await app.listen(process.env.PORT ?? 3000);
|
||||
console.log(`Aplicación corriendo en: http://localhost:${process.env.PORT ?? 3000}`);
|
||||
}
|
||||
bootstrap();
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
export const messageByStatus = {
|
||||
1: 'Aun no se puede contestar el cuestionario este Servicio Social.',
|
||||
2: 'Aun no se puede contestar el cuestionario este Servicio Social.',
|
||||
3: 'Aun no se puede contestar el cuestionario este Servicio Social.',
|
||||
5: 'Este Servicio Social ya paso la fase de contestar el cuestionario.',
|
||||
6: 'Este Servicio Social ya paso la fase de contestar el cuestionario.',
|
||||
7: 'Este Servicio Social se encuentra rechazado. No se puede avanzar hasta que se corrija lo necesario.',
|
||||
8: 'Este Servicio Social se encuentra rechazado. No se puede avanzar hasta que se corrija lo necesario.',
|
||||
9: 'Este Servicio Social se encuentra rechazado. No se puede avanzar hasta que se corrija lo necesario.',
|
||||
10: 'Este Servicio Social fue cancelado.',
|
||||
};
|
||||
@@ -0,0 +1 @@
|
||||
export class CreateProgramaDto {}
|
||||
@@ -0,0 +1,4 @@
|
||||
import { PartialType } from '@nestjs/mapped-types';
|
||||
import { CreateProgramaDto } from './create-programa.dto';
|
||||
|
||||
export class UpdateProgramaDto extends PartialType(CreateProgramaDto) {}
|
||||
@@ -0,0 +1,33 @@
|
||||
import { Servicio } from "src/servicio/entities/servicio.entity";
|
||||
import { Usuario } from "src/usuario/entities/usuario.entity";
|
||||
import { Column, Entity, ManyToOne, OneToMany, PrimaryGeneratedColumn } from "typeorm";
|
||||
|
||||
@Entity('programa')
|
||||
export class Programa {
|
||||
@PrimaryGeneratedColumn()
|
||||
idPrograma: number;
|
||||
|
||||
@Column({ type: 'varchar', length: 120 })
|
||||
institucion: string;
|
||||
|
||||
@Column({ type: 'varchar', length: 120 })
|
||||
dependencia: string;
|
||||
|
||||
@Column({ type: 'varchar', length: 280 })
|
||||
programa: string;
|
||||
|
||||
@Column({ type: 'varchar', length: 20 })
|
||||
clavePrograma: string;
|
||||
|
||||
@Column({ type: 'boolean', default: false })
|
||||
acatlan: boolean;
|
||||
|
||||
@Column({ type: 'boolean', default: true })
|
||||
activo: boolean;
|
||||
|
||||
@ManyToOne(()=>Usuario,(usuario)=>usuario.programa)
|
||||
usuario:Usuario;
|
||||
|
||||
@OneToMany(()=>Servicio,(servicio)=>servicio.cuestionarioAlumno2)
|
||||
servicio:Servicio[];
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
import { Controller, Get, Post, Body, Patch, Param, Delete } from '@nestjs/common';
|
||||
import { ProgramaService } from './programa.service';
|
||||
import { CreateProgramaDto } from './dto/create-programa.dto';
|
||||
import { UpdateProgramaDto } from './dto/update-programa.dto';
|
||||
|
||||
@Controller('programa')
|
||||
export class ProgramaController {
|
||||
constructor(private readonly programaService: ProgramaService) {}
|
||||
|
||||
@Post()
|
||||
create(@Body() createProgramaDto: CreateProgramaDto) {
|
||||
return this.programaService.create(createProgramaDto);
|
||||
}
|
||||
|
||||
@Get()
|
||||
findAll() {
|
||||
return this.programaService.findAll();
|
||||
}
|
||||
|
||||
@Get(':id')
|
||||
findOne(@Param('id') id: string) {
|
||||
return this.programaService.findOne(+id);
|
||||
}
|
||||
|
||||
@Patch(':id')
|
||||
update(@Param('id') id: string, @Body() updateProgramaDto: UpdateProgramaDto) {
|
||||
return this.programaService.update(+id, updateProgramaDto);
|
||||
}
|
||||
|
||||
@Delete(':id')
|
||||
remove(@Param('id') id: string) {
|
||||
return this.programaService.remove(+id);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { ProgramaService } from './programa.service';
|
||||
import { ProgramaController } from './programa.controller';
|
||||
|
||||
@Module({
|
||||
controllers: [ProgramaController],
|
||||
providers: [ProgramaService],
|
||||
})
|
||||
export class ProgramaModule {}
|
||||
@@ -0,0 +1,26 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { CreateProgramaDto } from './dto/create-programa.dto';
|
||||
import { UpdateProgramaDto } from './dto/update-programa.dto';
|
||||
|
||||
@Injectable()
|
||||
export class ProgramaService {
|
||||
create(createProgramaDto: CreateProgramaDto) {
|
||||
return 'This action adds a new programa';
|
||||
}
|
||||
|
||||
findAll() {
|
||||
return `This action returns all programa`;
|
||||
}
|
||||
|
||||
findOne(id: number) {
|
||||
return `This action returns a #${id} programa`;
|
||||
}
|
||||
|
||||
update(id: number, updateProgramaDto: UpdateProgramaDto) {
|
||||
return `This action updates a #${id} programa`;
|
||||
}
|
||||
|
||||
remove(id: number) {
|
||||
return `This action removes a #${id} programa`;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
export class CreateServicioDto {}
|
||||
@@ -0,0 +1,4 @@
|
||||
import { PartialType } from '@nestjs/mapped-types';
|
||||
import { CreateServicioDto } from './create-servicio.dto';
|
||||
|
||||
export class UpdateServicioDto extends PartialType(CreateServicioDto) {}
|
||||
@@ -0,0 +1,88 @@
|
||||
import { Carrera } from "src/carrera/entities/carrera.entity";
|
||||
import { CuestionarioAlumno } from "src/cuestionario-alumno/entities/cuestionario-alumno.entity";
|
||||
import { CuestionarioAlumno2 } from "src/cuestionario-alumno2/entities/cuestionario-alumno2.entity";
|
||||
import { CuestionarioPrograma } from "src/cuestionario-programa/entities/cuestionario-programa.entity";
|
||||
import { CuestionarioPrograma2 } from "src/cuestionario-programa2/entities/cuestionario-programa2.entity";
|
||||
import { Programa } from "src/programa/entities/programa.entity";
|
||||
import { Status } from "src/status/entities/status.entity";
|
||||
import { Usuario } from "src/usuario/entities/usuario.entity";
|
||||
import { Column, Entity, ManyToOne, PrimaryGeneratedColumn } from "typeorm";
|
||||
|
||||
@Entity('servicio')
|
||||
export class Servicio {
|
||||
|
||||
@PrimaryGeneratedColumn()
|
||||
idServicio: number;
|
||||
|
||||
@Column({ type: 'varchar', length: 3 })
|
||||
creditos: string;
|
||||
|
||||
@Column({ type: 'varchar', length: 60 })
|
||||
correo: string;
|
||||
|
||||
@Column({ type: 'varchar', length: 15, nullable: true, default: null })
|
||||
telefono?: string;
|
||||
|
||||
@Column({ type: 'varchar', length: 200, nullable: true, default: null })
|
||||
direccion?: string;
|
||||
|
||||
@Column({ type: 'date' })
|
||||
fechaInicio: Date;
|
||||
|
||||
@Column({ type: 'date' })
|
||||
fechaFin: Date;
|
||||
|
||||
@Column({ type: 'date', nullable: true, default: null })
|
||||
fechaLiberacion?: Date;
|
||||
|
||||
@Column({ type: 'date', nullable: true, default: null })
|
||||
fechaNacimiento?: Date;
|
||||
|
||||
@Column({ type: 'varchar', length: 60 })
|
||||
carpeta: string;
|
||||
|
||||
@Column({ type: 'varchar', length: 60 })
|
||||
cartaAceptacion: string;
|
||||
|
||||
@Column({ type: 'varchar', length: 60, nullable: true, default: null })
|
||||
cartaTermino?: string;
|
||||
|
||||
@Column({ type: 'varchar', length: 60, nullable: true, default: null })
|
||||
informeGlobal?: string;
|
||||
|
||||
@Column({ type: 'varchar', length: 250, nullable: true, default: null })
|
||||
programaInterno?: string;
|
||||
|
||||
@Column({ type: 'varchar', length: 50, nullable: true, default: null })
|
||||
profesor?: string;
|
||||
|
||||
@Column({ type: 'boolean', nullable: true, default: null })
|
||||
vistoBuenoAcatlan?: boolean;
|
||||
|
||||
@ManyToOne(()=>Usuario,(usuario)=>usuario.servicio)
|
||||
usuario:Usuario
|
||||
|
||||
@ManyToOne(()=>CuestionarioAlumno2,(cuestionarioAlumno2)=>cuestionarioAlumno2.servicio)
|
||||
cuestionarioAlumno2:CuestionarioAlumno2;
|
||||
|
||||
@ManyToOne(()=>CuestionarioPrograma2,(cuestionarioPrograma2)=>cuestionarioPrograma2.servicio)
|
||||
cuestionarioPrograma2:CuestionarioPrograma2;
|
||||
|
||||
@ManyToOne(()=>CuestionarioPrograma,(cuestionarioPrograma)=>cuestionarioPrograma.servicio)
|
||||
cuestionarioPrograma:CuestionarioPrograma;
|
||||
|
||||
@ManyToOne(()=>CuestionarioAlumno,(cuestionarioAlumno)=>cuestionarioAlumno.servicio)
|
||||
cuestionarioAlumno:CuestionarioAlumno;
|
||||
|
||||
@ManyToOne(()=>Status,(status)=>status.servicio)
|
||||
status:Status;
|
||||
|
||||
@ManyToOne(()=>Programa,(programa)=>programa.servicio)
|
||||
programa:Programa;
|
||||
|
||||
@ManyToOne(()=>Carrera,(carrera)=>carrera.servicio)
|
||||
carrera:Carrera;
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
import { Controller, Get, Post, Body, Patch, Param, Delete } from '@nestjs/common';
|
||||
import { ServicioService } from './servicio.service';
|
||||
import { CreateServicioDto } from './dto/create-servicio.dto';
|
||||
import { UpdateServicioDto } from './dto/update-servicio.dto';
|
||||
|
||||
@Controller('servicio')
|
||||
export class ServicioController {
|
||||
constructor(private readonly servicioService: ServicioService) {}
|
||||
|
||||
@Post()
|
||||
create(@Body() createServicioDto: CreateServicioDto) {
|
||||
return this.servicioService.create(createServicioDto);
|
||||
}
|
||||
|
||||
@Get()
|
||||
findAll() {
|
||||
return this.servicioService.findAll();
|
||||
}
|
||||
|
||||
@Get(':id')
|
||||
findOne(@Param('id') id: string) {
|
||||
return this.servicioService.findOne(+id);
|
||||
}
|
||||
|
||||
@Patch(':id')
|
||||
update(@Param('id') id: string, @Body() updateServicioDto: UpdateServicioDto) {
|
||||
return this.servicioService.update(+id, updateServicioDto);
|
||||
}
|
||||
|
||||
@Delete(':id')
|
||||
remove(@Param('id') id: string) {
|
||||
return this.servicioService.remove(+id);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { ServicioService } from './servicio.service';
|
||||
import { ServicioController } from './servicio.controller';
|
||||
|
||||
@Module({
|
||||
controllers: [ServicioController],
|
||||
providers: [ServicioService],
|
||||
})
|
||||
export class ServicioModule {}
|
||||
@@ -0,0 +1,26 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { CreateServicioDto } from './dto/create-servicio.dto';
|
||||
import { UpdateServicioDto } from './dto/update-servicio.dto';
|
||||
|
||||
@Injectable()
|
||||
export class ServicioService {
|
||||
create(createServicioDto: CreateServicioDto) {
|
||||
return 'This action adds a new servicio';
|
||||
}
|
||||
|
||||
findAll() {
|
||||
return `This action returns all servicio`;
|
||||
}
|
||||
|
||||
findOne(id: number) {
|
||||
return `This action returns a #${id} servicio`;
|
||||
}
|
||||
|
||||
update(id: number, updateServicioDto: UpdateServicioDto) {
|
||||
return `This action updates a #${id} servicio`;
|
||||
}
|
||||
|
||||
remove(id: number) {
|
||||
return `This action removes a #${id} servicio`;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
export class CreateStatusDto {}
|
||||
@@ -0,0 +1,4 @@
|
||||
import { PartialType } from '@nestjs/mapped-types';
|
||||
import { CreateStatusDto } from './create-status.dto';
|
||||
|
||||
export class UpdateStatusDto extends PartialType(CreateStatusDto) {}
|
||||
@@ -0,0 +1,19 @@
|
||||
import { CasoEspecial } from "src/caso-especial/entities/caso-especial.entity";
|
||||
import { Servicio } from "src/servicio/entities/servicio.entity";
|
||||
import { Column, Entity, OneToMany, PrimaryGeneratedColumn } from "typeorm";
|
||||
|
||||
|
||||
@Entity('status')
|
||||
export class Status {
|
||||
@PrimaryGeneratedColumn()
|
||||
idStatus: number;
|
||||
|
||||
@Column({ type: 'varchar', length: 30 })
|
||||
status: string;
|
||||
|
||||
@OneToMany(()=>Servicio, (servicio)=>servicio.status)
|
||||
servicio:Servicio[];
|
||||
|
||||
@OneToMany(()=>CasoEspecial, (casoEspecial)=>casoEspecial.status)
|
||||
casoEspecial:CasoEspecial[];
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
import { Controller, Get, Post, Body, Patch, Param, Delete } from '@nestjs/common';
|
||||
import { StatusService } from './status.service';
|
||||
import { CreateStatusDto } from './dto/create-status.dto';
|
||||
import { UpdateStatusDto } from './dto/update-status.dto';
|
||||
|
||||
@Controller('status')
|
||||
export class StatusController {
|
||||
constructor(private readonly statusService: StatusService) {}
|
||||
|
||||
@Post()
|
||||
create(@Body() createStatusDto: CreateStatusDto) {
|
||||
return this.statusService.create(createStatusDto);
|
||||
}
|
||||
|
||||
@Get()
|
||||
findAll() {
|
||||
return this.statusService.findAll();
|
||||
}
|
||||
|
||||
@Get(':id')
|
||||
findOne(@Param('id') id: string) {
|
||||
return this.statusService.findOne(+id);
|
||||
}
|
||||
|
||||
@Patch(':id')
|
||||
update(@Param('id') id: string, @Body() updateStatusDto: UpdateStatusDto) {
|
||||
return this.statusService.update(+id, updateStatusDto);
|
||||
}
|
||||
|
||||
@Delete(':id')
|
||||
remove(@Param('id') id: string) {
|
||||
return this.statusService.remove(+id);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { StatusService } from './status.service';
|
||||
import { StatusController } from './status.controller';
|
||||
|
||||
@Module({
|
||||
controllers: [StatusController],
|
||||
providers: [StatusService],
|
||||
})
|
||||
export class StatusModule {}
|
||||
@@ -0,0 +1,26 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { CreateStatusDto } from './dto/create-status.dto';
|
||||
import { UpdateStatusDto } from './dto/update-status.dto';
|
||||
|
||||
@Injectable()
|
||||
export class StatusService {
|
||||
create(createStatusDto: CreateStatusDto) {
|
||||
return 'This action adds a new status';
|
||||
}
|
||||
|
||||
findAll() {
|
||||
return `This action returns all status`;
|
||||
}
|
||||
|
||||
findOne(id: number) {
|
||||
return `This action returns a #${id} status`;
|
||||
}
|
||||
|
||||
update(id: number, updateStatusDto: UpdateStatusDto) {
|
||||
return `This action updates a #${id} status`;
|
||||
}
|
||||
|
||||
remove(id: number) {
|
||||
return `This action removes a #${id} status`;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
export class CreateTipoUsuarioDto {}
|
||||
@@ -0,0 +1,4 @@
|
||||
import { PartialType } from '@nestjs/mapped-types';
|
||||
import { CreateTipoUsuarioDto } from './create-tipo-usuario.dto';
|
||||
|
||||
export class UpdateTipoUsuarioDto extends PartialType(CreateTipoUsuarioDto) {}
|
||||
@@ -0,0 +1,16 @@
|
||||
import { Usuario } from "src/usuario/entities/usuario.entity";
|
||||
import { Column, Entity, OneToMany, PrimaryGeneratedColumn } from "typeorm";
|
||||
|
||||
@Entity('tipo_usuario')
|
||||
export class TipoUsuario {
|
||||
|
||||
@PrimaryGeneratedColumn()
|
||||
idTipoUsuario: number;
|
||||
|
||||
@Column({ type: 'varchar', length: 15 })
|
||||
tipoUsuario: string;
|
||||
|
||||
@OneToMany(()=>Usuario, (usuario)=>usuario.tipoUsuario)
|
||||
usuario:Usuario;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
import { Controller, Get, Post, Body, Patch, Param, Delete } from '@nestjs/common';
|
||||
import { TipoUsuarioService } from './tipo-usuario.service';
|
||||
import { CreateTipoUsuarioDto } from './dto/create-tipo-usuario.dto';
|
||||
import { UpdateTipoUsuarioDto } from './dto/update-tipo-usuario.dto';
|
||||
|
||||
@Controller('tipo-usuario')
|
||||
export class TipoUsuarioController {
|
||||
constructor(private readonly tipoUsuarioService: TipoUsuarioService) {}
|
||||
|
||||
@Post()
|
||||
create(@Body() createTipoUsuarioDto: CreateTipoUsuarioDto) {
|
||||
return this.tipoUsuarioService.create(createTipoUsuarioDto);
|
||||
}
|
||||
|
||||
@Get()
|
||||
findAll() {
|
||||
return this.tipoUsuarioService.findAll();
|
||||
}
|
||||
|
||||
@Get(':id')
|
||||
findOne(@Param('id') id: string) {
|
||||
return this.tipoUsuarioService.findOne(+id);
|
||||
}
|
||||
|
||||
@Patch(':id')
|
||||
update(@Param('id') id: string, @Body() updateTipoUsuarioDto: UpdateTipoUsuarioDto) {
|
||||
return this.tipoUsuarioService.update(+id, updateTipoUsuarioDto);
|
||||
}
|
||||
|
||||
@Delete(':id')
|
||||
remove(@Param('id') id: string) {
|
||||
return this.tipoUsuarioService.remove(+id);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { TipoUsuarioService } from './tipo-usuario.service';
|
||||
import { TipoUsuarioController } from './tipo-usuario.controller';
|
||||
|
||||
@Module({
|
||||
controllers: [TipoUsuarioController],
|
||||
providers: [TipoUsuarioService],
|
||||
})
|
||||
export class TipoUsuarioModule {}
|
||||
@@ -0,0 +1,26 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { CreateTipoUsuarioDto } from './dto/create-tipo-usuario.dto';
|
||||
import { UpdateTipoUsuarioDto } from './dto/update-tipo-usuario.dto';
|
||||
|
||||
@Injectable()
|
||||
export class TipoUsuarioService {
|
||||
create(createTipoUsuarioDto: CreateTipoUsuarioDto) {
|
||||
return 'This action adds a new tipoUsuario';
|
||||
}
|
||||
|
||||
findAll() {
|
||||
return `This action returns all tipoUsuario`;
|
||||
}
|
||||
|
||||
findOne(id: number) {
|
||||
return `This action returns a #${id} tipoUsuario`;
|
||||
}
|
||||
|
||||
update(id: number, updateTipoUsuarioDto: UpdateTipoUsuarioDto) {
|
||||
return `This action updates a #${id} tipoUsuario`;
|
||||
}
|
||||
|
||||
remove(id: number) {
|
||||
return `This action removes a #${id} tipoUsuario`;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
export class CreateUsuarioDto {}
|
||||
@@ -0,0 +1,4 @@
|
||||
import { PartialType } from '@nestjs/mapped-types';
|
||||
import { CreateUsuarioDto } from './create-usuario.dto';
|
||||
|
||||
export class UpdateUsuarioDto extends PartialType(CreateUsuarioDto) {}
|
||||
@@ -0,0 +1,38 @@
|
||||
import { CasoEspecial } from "src/caso-especial/entities/caso-especial.entity";
|
||||
import { Programa } from "src/programa/entities/programa.entity";
|
||||
import { Servicio } from "src/servicio/entities/servicio.entity";
|
||||
import { TipoUsuario } from "src/tipo-usuario/entities/tipo-usuario.entity";
|
||||
import { Column, Entity, ManyToMany, ManyToOne, OneToMany, PrimaryGeneratedColumn, Unique } from "typeorm";
|
||||
|
||||
@Entity('usuario')
|
||||
@Unique(['usuario'])
|
||||
export class Usuario {
|
||||
|
||||
@PrimaryGeneratedColumn()
|
||||
idUsuario: number;
|
||||
|
||||
@Column({ type: 'varchar', length: 100 })
|
||||
usuario: string;
|
||||
|
||||
@Column({ type: 'varchar', length: 60, nullable: true, default: null })
|
||||
password: string | null;
|
||||
|
||||
@Column({ type: 'varchar', length: 70, nullable: true, default: null })
|
||||
nombre: string | null;
|
||||
|
||||
@Column({ type: 'boolean', default: true })
|
||||
activo: boolean;
|
||||
|
||||
@ManyToOne(()=>TipoUsuario,(tipoUsuario)=>tipoUsuario.usuario)
|
||||
tipoUsuario:TipoUsuario;
|
||||
|
||||
@OneToMany(()=>CasoEspecial,(casoEspecial)=>casoEspecial.usuario)
|
||||
casoEspecial:CasoEspecial[];
|
||||
|
||||
@OneToMany(()=>Programa,(programa)=>programa.usuario)
|
||||
programa:Programa[];
|
||||
|
||||
@OneToMany(()=>Servicio,(servicio)=>servicio.usuario)
|
||||
servicio:Servicio[];
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
import { Controller, Get, Post, Body, Patch, Param, Delete } from '@nestjs/common';
|
||||
import { UsuarioService } from './usuario.service';
|
||||
import { CreateUsuarioDto } from './dto/create-usuario.dto';
|
||||
import { UpdateUsuarioDto } from './dto/update-usuario.dto';
|
||||
|
||||
@Controller('usuario')
|
||||
export class UsuarioController {
|
||||
constructor(private readonly usuarioService: UsuarioService) {}
|
||||
|
||||
@Post()
|
||||
create(@Body() createUsuarioDto: CreateUsuarioDto) {
|
||||
return this.usuarioService.create(createUsuarioDto);
|
||||
}
|
||||
|
||||
@Get()
|
||||
findAll() {
|
||||
return this.usuarioService.findAll();
|
||||
}
|
||||
|
||||
@Get(':id')
|
||||
findOne(@Param('id') id: string) {
|
||||
return this.usuarioService.findOne(+id);
|
||||
}
|
||||
|
||||
@Patch(':id')
|
||||
update(@Param('id') id: string, @Body() updateUsuarioDto: UpdateUsuarioDto) {
|
||||
return this.usuarioService.update(+id, updateUsuarioDto);
|
||||
}
|
||||
|
||||
@Delete(':id')
|
||||
remove(@Param('id') id: string) {
|
||||
return this.usuarioService.remove(+id);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { UsuarioService } from './usuario.service';
|
||||
import { UsuarioController } from './usuario.controller';
|
||||
|
||||
@Module({
|
||||
controllers: [UsuarioController],
|
||||
providers: [UsuarioService],
|
||||
})
|
||||
export class UsuarioModule {}
|
||||
@@ -0,0 +1,26 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { CreateUsuarioDto } from './dto/create-usuario.dto';
|
||||
import { UpdateUsuarioDto } from './dto/update-usuario.dto';
|
||||
|
||||
@Injectable()
|
||||
export class UsuarioService {
|
||||
create(createUsuarioDto: CreateUsuarioDto) {
|
||||
return 'This action adds a new usuario';
|
||||
}
|
||||
|
||||
findAll() {
|
||||
return `This action returns all usuario`;
|
||||
}
|
||||
|
||||
findOne(id: number) {
|
||||
return `This action returns a #${id} usuario`;
|
||||
}
|
||||
|
||||
update(id: number, updateUsuarioDto: UpdateUsuarioDto) {
|
||||
return `This action updates a #${id} usuario`;
|
||||
}
|
||||
|
||||
remove(id: number) {
|
||||
return `This action removes a #${id} usuario`;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,172 @@
|
||||
import { Injectable } from "@nestjs/common";
|
||||
import { InjectRepository } from "@nestjs/typeorm";
|
||||
import moment from "moment";
|
||||
import { Servicio } from "src/servicio/entities/servicio.entity";
|
||||
import { Repository } from "typeorm";
|
||||
import validator from "validator";
|
||||
|
||||
|
||||
@Injectable()
|
||||
export class ValidacionService {
|
||||
constructor(
|
||||
@InjectRepository(Servicio)
|
||||
private servicioRepository:Repository<Servicio>,
|
||||
){}
|
||||
|
||||
caracterEspecial(char) {
|
||||
const charset = [' ', '.', ',', ':', ';', '?', '¿', '!', '¡', '(', ')', '"', "'", '-', '_', '/', '#', '%', '\n'];
|
||||
return charset.includes(char);
|
||||
}
|
||||
|
||||
yaExiste(campo, m) {
|
||||
throw new Error(`Ya se encuentra en uso ${m ? 'el' : 'la'} ${campo}.`);
|
||||
}
|
||||
|
||||
noValido(campo, m, razon) {
|
||||
throw new Error(`${m ? 'El' : 'La'} ${campo} no es valid${m ? 'o' : 'a'}, ${razon}.`);
|
||||
}
|
||||
|
||||
noHay(variable, campo, m) {
|
||||
if (!variable) throw new Error(`No se mando ${m ? 'el' : 'la'} ${campo}.`);
|
||||
}
|
||||
|
||||
validacionBasicaStr(texto, campo, m, length) {
|
||||
this.noHay(texto, campo, m);
|
||||
if (typeof texto !== 'string') this.noValido(campo, m, 'no se mando una string');
|
||||
if (length && texto.length > length) this.noValido(campo, m, 'tiene más caracteres de lo permitido');
|
||||
return texto;
|
||||
}
|
||||
|
||||
validarNumeroEntero(numero, campo, m = true) {
|
||||
this.noHay(numero, campo, m);
|
||||
if (typeof numero === 'number') numero = numero.toString();
|
||||
if (!validator.isNumeric(numero, { no_symbols: true })) this.noValido(campo, m, 'no es un número entero válido');
|
||||
return Number(numero);
|
||||
}
|
||||
|
||||
validarCorreo(correo, campo = 'correo', m = true, length) {
|
||||
this.validacionBasicaStr(correo, campo, m, length);
|
||||
if (!validator.isEmail(correo)) this.noValido(campo, m, 'no es un correo válido');
|
||||
return correo;
|
||||
}
|
||||
|
||||
validarTexto(texto, campo, m, length) {
|
||||
this.validacionBasicaStr(texto, campo, m, length);
|
||||
for (const char of texto) {
|
||||
if (!validator.isAlpha(char, 'es-ES') && char !== ' ' && char !== '.') {
|
||||
this.noValido(campo, m, 'contiene caracteres no válidos');
|
||||
}
|
||||
}
|
||||
return texto;
|
||||
}
|
||||
|
||||
validarAlfanumerico(texto, campo, m, length) {
|
||||
this.validacionBasicaStr(texto, campo, m, length);
|
||||
for (const char of texto) {
|
||||
if (!this.caracterEspecial(char) && !validator.isAlphanumeric(char, 'es-ES')) {
|
||||
this.noValido(campo, m, 'contiene caracteres no válidos');
|
||||
}
|
||||
}
|
||||
return texto;
|
||||
}
|
||||
|
||||
validarNumeroCuenta(numeroCuenta, campo = 'numero de cuenta', m = true) {
|
||||
this.validacionBasicaStr(numeroCuenta, campo, m, 9);
|
||||
if (!validator.isNumeric(numeroCuenta, { no_symbols: true })) {
|
||||
this.noValido(campo, m, 'tiene caracteres que no son números');
|
||||
}
|
||||
return numeroCuenta;
|
||||
}
|
||||
|
||||
validarFecha(fecha, campo, m) {
|
||||
const fechaMoment = moment(fecha);
|
||||
this.noHay(fecha, campo, m);
|
||||
if (!fechaMoment.isValid()) this.noValido(campo, m, 'no es una fecha válida');
|
||||
return fechaMoment;
|
||||
}
|
||||
|
||||
validarNumero(numero, campo, m, length, no_symbols = true, makeNumber = false) {
|
||||
this.validacionBasicaStr(numero, campo, m, length);
|
||||
if (!validator.isNumeric(numero, { no_symbols })) {
|
||||
this.noValido(campo, m, 'tiene caracteres que no son números');
|
||||
}
|
||||
return makeNumber ? Number(numero) : numero;
|
||||
}
|
||||
|
||||
validarObjetoVacio(obj) {
|
||||
return Object.keys(obj).length === 0;
|
||||
}
|
||||
|
||||
async validarPreTermino(idServicio) {
|
||||
const res = await this.servicioRepository.findOne({ where: { idServicio } });
|
||||
|
||||
if (
|
||||
(res?.cuestionarioPrograma.idCuestionarioPrograma || res?.cuestionarioPrograma2.idCuestionarioPrograma2) &&
|
||||
(res.cuestionarioAlumno.idCuestionarioAlumno || res.cuestionarioAlumno2.idCuestionarioAlumno2) &&
|
||||
res.cartaTermino &&
|
||||
res.informeGlobal
|
||||
) {
|
||||
await this.servicioRepository.update({ idServicio }, { status: {idStatus:5} });
|
||||
return 'Este Servicio Social pasó a Término, espera a que COESI autorice tu liberación.';
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
validarCuestionarioAlumno2(body) {
|
||||
const optionalKeys = ['p5', 'p8', 'p16', 'p18'];
|
||||
if (Array.isArray(body.p1)) body.p1 = body.p1.join(', ');
|
||||
|
||||
for (const [key, value] of Object.entries(body)) {
|
||||
if (!optionalKeys.includes(key) && (value === null || value === undefined || value === '')) {
|
||||
throw new Error(`El campo ${key} no puede estar vacío.`);
|
||||
}
|
||||
}
|
||||
|
||||
const expectedKeys = [
|
||||
'p1', 'p2', 'p4', 'p6', 'p7', 'p9', 'p13', 'p14', 'p15',
|
||||
'p3_1', 'p3_2', 'p3_3', 'p3_4',
|
||||
'p10_1', 'p10_2', 'p10_3',
|
||||
'p11_1', 'p11_2', 'p11_3', 'p11_4',
|
||||
'p17_1', 'p17_2', 'p17_3',
|
||||
'p12_A_1', 'p12_A_2', 'p12_A_3', 'p12_A_4',
|
||||
'p12_B_1', 'p12_B_2', 'p12_B_3', 'p12_B_4',
|
||||
'p12_C_1', 'p12_C_2', 'p12_C_3', 'p12_C_4', 'p12_C_5',
|
||||
'p12_D_1', 'p12_D_2', 'p12_D_3', 'p12_D_4', 'p12_D_5'
|
||||
];
|
||||
|
||||
for (const key of expectedKeys) {
|
||||
if (!(key in body)) {
|
||||
throw new Error(`Falta la respuesta para la pregunta ${key}.`);
|
||||
}
|
||||
}
|
||||
|
||||
return body;
|
||||
}
|
||||
|
||||
validarCuestionarioPrograma2(body) {
|
||||
const camposOpcionales = ['p6'];
|
||||
if (Array.isArray(body.p1)) body.p1 = body.p1.join(', ');
|
||||
|
||||
for (const [key, value] of Object.entries(body)) {
|
||||
if (!camposOpcionales.includes(key) && (value === null || value === undefined || value === '')) {
|
||||
throw new Error(`El campo ${key} no puede estar vacío.`);
|
||||
}
|
||||
}
|
||||
|
||||
const expectedKeys = [
|
||||
'p1', 'p2', 'p4', 'p5',
|
||||
'p3_A_1', 'p3_A_2', 'p3_A_3', 'p3_A_4',
|
||||
'p3_B_1', 'p3_B_2', 'p3_B_3', 'p3_B_4',
|
||||
'p3_C_1', 'p3_C_2', 'p3_C_3', 'p3_C_4', 'p3_C_5',
|
||||
'p3_D_1', 'p3_D_2', 'p3_D_3', 'p3_D_4', 'p3_D_5'
|
||||
];
|
||||
|
||||
for (const key of expectedKeys) {
|
||||
if (!(key in body)) {
|
||||
throw new Error(`Falta la respuesta para la pregunta ${key}.`);
|
||||
}
|
||||
}
|
||||
|
||||
return body;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user