diff --git a/.gitignore b/.gitignore index 1c1827d..50d9976 100644 --- a/.gitignore +++ b/.gitignore @@ -19,6 +19,9 @@ lerna-debug.log* /coverage /.nyc_output +# Ignorar credenciales sensibles +cred.json + # IDEs and editors /.idea .project diff --git a/docker-compose.yml b/docker-compose.yml index cb6919f..161c0f5 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,33 +1,20 @@ -version: '3.8' - services: - mysql: + database: image: mariadb:latest - container_name: Iris_db + container_name: Iris_api restart: always environment: - MYSQL_ROOT_PASSWORD: root - MYSQL_DATABASE: Iris - MYSQL_USER: user_crud - MYSQL_PASSWORD: root + - MARIADB_ROOT_PASSWORD=root + - MARIADB_DATABASE=Iris_testDB + - MARIADB_USER=miusuario + - MARIADB_PASSWORD=root + env_file: + - ../Iris_back/.env + ports: + - '${DB_PORT}:3306' volumes: - - ./mysql:/var/lib/mysql - ports: - - "3307:3306" + - mariadb_data:/var/lib/mysql + - ./init.sql:/docker-entrypoint-initdb.d/init.sql - nest-app: - build: - context: . - dockerfile: Dockerfile - container_name: Iris_app - restart: always - depends_on: - - mysql - environment: - DATABASE_HOST: mysql - DATABASE_PORT: 3306 - DATABASE_USER: user_crud - DATABASE_PASSWORD: root - DATABASE_NAME: Iris - ports: - - "3000:3000" +volumes: + mariadb_data: diff --git a/package.json b/package.json index d7a18da..a4d0af3 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "scripts": { "build": "nest build", "format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"", - "start": "source ~/.nvm/nvm.sh && nvm use 22.10.0 && npm install && nest start", + "start": "nest start", "start:dev": "nest start --watch", "start:debug": "nest start --debug --watch", "start:prod": "node dist/main", diff --git a/src/app.module.ts b/src/app.module.ts index 5b0b6e9..bf6d1df 100644 --- a/src/app.module.ts +++ b/src/app.module.ts @@ -20,16 +20,15 @@ import { UsuarioModule } from './usuario/usuario.module'; 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), + type: 'mariadb', + 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: false, // Carga automáticamente las entidades + dropSchema: false, + autoLoadEntities: true, }), CarreraModule, diff --git a/src/carrera/carrera.controller.ts b/src/carrera/carrera.controller.ts deleted file mode 100644 index 2f10861..0000000 --- a/src/carrera/carrera.controller.ts +++ /dev/null @@ -1,42 +0,0 @@ -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); - } -} diff --git a/src/carrera/entities/carrera.entity.ts b/src/carrera/entities/carrera.entity.ts index 3f5682a..2249f65 100644 --- a/src/carrera/entities/carrera.entity.ts +++ b/src/carrera/entities/carrera.entity.ts @@ -1,19 +1,24 @@ -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"; - +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; + @PrimaryGeneratedColumn() + idCarrera: number; - @Column({type: 'varchar', length: 50, nullable: false}) - carrera:string; + @Column({ type: 'varchar', length: 50 }) + carrera: string; - @OneToMany(()=>Servicio, (servicio)=>servicio.carrera) - servicio:Servicio[]; + @OneToMany(() => Servicio, (servicio) => servicio.carrera) + servicio: Servicio[]; - @OneToMany(()=>CasoEspecial,(casoEspecial)=>casoEspecial.carrera) - casoEspecial:CasoEspecial[]; + @OneToMany(() => CasoEspecial, (casoEspecial) => casoEspecial.carrera) + casoEspecial: CasoEspecial[]; } diff --git a/src/caso-especial/entities/caso-especial.entity.ts b/src/caso-especial/entities/caso-especial.entity.ts index cc21f35..e012c72 100644 --- a/src/caso-especial/entities/caso-especial.entity.ts +++ b/src/caso-especial/entities/caso-especial.entity.ts @@ -1,63 +1,71 @@ -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, ManyToOne, PrimaryGeneratedColumn } from "typeorm"; +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, + JoinColumn, + ManyToMany, + ManyToOne, + PrimaryGeneratedColumn, +} from 'typeorm'; @Entity('caso_especial') export class CasoEspecial { - @PrimaryGeneratedColumn() - idCasoEspecial: number; + @PrimaryGeneratedColumn({ name: 'idCasoEspecial', type: 'int' }) + idCasoEspecial: number; - @Column({ type: 'varchar', length: 3 }) - creditos: string; + @Column({ name: 'creditos', type: 'varchar', length: 3 }) + creditos: string; - @Column({ type: 'varchar', length: 60 }) - correo: string; + @Column({ name: 'correo', type: 'varchar', length: 60 }) + correo: string; - @Column({ type: 'varchar', length: 15 }) - telefono: string; + @Column({ name: 'telefono', type: 'varchar', length: 15 }) + telefono: string; - @Column({ type: 'varchar', length: 200, nullable: true, default: null }) - institucion: string | null; + @Column({ name: 'institucion', type: 'varchar', length: 200 }) + institucion: string; - @Column({ type: 'varchar', length: 200, nullable: true, default: null }) - dependencia: string | null; + @Column({ name: 'dependencia', type: 'varchar', length: 200 }) + dependencia: string; - @Column({ type: 'varchar', length: 1, nullable: true, default: null }) - motivo: string | null; + @Column({ name: 'motivo', type: 'varchar', length: 1 }) + motivo: string; - @Column({ type: 'varchar', length: 200 }) - direccion: string; + @Column({ name: 'direccion', type: 'varchar', length: 200 }) + direccion: string; - @Column({ type: 'timestamp' }) - fechaInicio: Date; + @Column({ name: 'fechaInicio', type: 'datetime' }) + fechaInicio: Date; - @Column({ type: 'timestamp' }) - fechaFin: Date; + @Column({ name: 'fechaFin', type: 'datetime' }) + fechaFin: Date; - @Column({ type: 'timestamp' }) - fechaNacimiento: Date; + @Column({ name: 'fechaNacimiento', type: 'datetime' }) + fechaNacimiento: Date; - @Column({ type: 'varchar', length: 60 }) - carpeta: string; + @Column({ name: 'carpeta', type: 'varchar', length: 60 }) + carpeta: string; - @Column({ type: 'varchar', length: 60 }) - archivoZip: string; - - @Column({ type: 'timestamp', default: () => 'CURRENT_TIMESTAMP' }) - createdAt: Date; + @Column({ name: 'archivoZip', type: 'varchar', length: 60 }) + archivoZip: string; - @Column({ type: 'timestamp', default: () => 'CURRENT_TIMESTAMP', onUpdate: 'CURRENT_TIMESTAMP' }) - updatedAt: Date; + @Column({ name: 'createdAt', type: 'datetime' }) + createdAt: Date; - @ManyToOne(()=>Usuario, (usuario)=>usuario.casoEspecial) - usuario:Usuario; + @Column({ name: 'updatedAt', type: 'datetime' }) + updatedAt: Date; - @ManyToOne(()=>Carrera, (carrera)=>carrera.casoEspecial) - carrera:Carrera; - - @ManyToOne(()=>Status, (status)=>status.casoEspecial) - status:Status; + @ManyToOne(() => Usuario, (usuario) => usuario.casoEspecial) + @JoinColumn({ name: 'idUsuario' }) + usuario: Usuario; + @ManyToOne(() => Carrera, (carrera) => carrera.casoEspecial) + @JoinColumn({ name: 'idCarrera' }) + carrera: Carrera; + @ManyToOne(() => Status, (status) => status.casoEspecial) + @JoinColumn({ name: 'idStatus' }) + status: Status; } diff --git a/src/cuestionario-alumno/entities/cuestionario-alumno.entity.ts b/src/cuestionario-alumno/entities/cuestionario-alumno.entity.ts index 135ee85..aeacaac 100644 --- a/src/cuestionario-alumno/entities/cuestionario-alumno.entity.ts +++ b/src/cuestionario-alumno/entities/cuestionario-alumno.entity.ts @@ -1,111 +1,113 @@ -import { Servicio } from "src/servicio/entities/servicio.entity"; -import { Column, Entity, OneToMany, PrimaryGeneratedColumn } from "typeorm"; +import { Servicio } from 'src/servicio/entities/servicio.entity'; +import { Column, Entity, OneToMany, PrimaryGeneratedColumn } from 'typeorm'; @Entity('cuestionario_alumno') export class CuestionarioAlumno { - @PrimaryGeneratedColumn() - idCuestionarioAlumno: number; + @PrimaryGeneratedColumn({ name: 'idCuestionarioAlumno', type: 'int' }) + idCuestionarioAlumno: number; - @Column({ type: 'varchar', length: 1 }) - sexo: string; + @Column({ name: 'sexo', type: 'varchar', length: 1 }) + sexo: string; - @Column({ type: 'varchar', length: 2 }) - edad: string; + @Column({ name: 'edad', type: 'varchar', length: 2 }) + edad: string; - @Column({ type: 'varchar', length: 100 }) - servicioMedico: string; + @Column({ name: 'servicioMedico', type: 'varchar', length: 100 }) + servicioMedico: string; - @Column() - p1: boolean; + @Column({ name: 'p1', type: 'tinyint', width: 1 }) + p1: number; - @Column() - p2: boolean; + @Column({ name: 'p2', type: 'tinyint', width: 1 }) + p2: number; - @Column({ type: 'varchar', length: 150 }) - p3: string; + @Column({ name: 'p3', type: 'varchar', length: 150 }) + p3: string; - @Column() - p4: boolean; + @Column({ name: 'p4', type: 'tinyint', width: 1 }) + p4: number; - @Column({ type: 'varchar', length: 7 }) - p5: string; + @Column({ name: 'p5', type: 'varchar', length: 7 }) + p5: string; - @Column() - p6: boolean; + @Column({ name: 'p6', type: 'tinyint', width: 1 }) + p6: number; - @Column() - p7: boolean; + @Column({ name: 'p7', type: 'tinyint', width: 1 }) + p7: number; - @Column({ type: 'varchar', length: 5 }) - p8: string; + @Column({ name: 'p8', type: 'varchar', length: 5 }) + p8: string; - @Column() - p9: boolean; + @Column({ name: 'p9', type: 'tinyint', width: 1 }) + p9: number; - @Column() - p10: boolean; + @Column({ name: 'p10', type: 'tinyint', width: 1 }) + p10: number; - @Column() - p11: boolean; + @Column({ name: 'p11', type: 'tinyint', width: 1 }) + p11: number; - @Column() - p12: boolean; + @Column({ name: 'p12', type: 'tinyint', width: 1 }) + p12: number; - @Column() - p13: boolean; + @Column({ name: 'p13', type: 'tinyint', width: 1 }) + p13: number; - @Column({ type: 'varchar', length: 7 }) - p14: string; + @Column({ name: 'p14', type: 'varchar', length: 7 }) + p14: string; - @Column({ type: 'varchar', length: 7 }) - p15: string; + @Column({ name: 'p15', type: 'varchar', length: 7 }) + p15: string; - @Column({ type: 'varchar', length: 2 }) - p16: string; + @Column({ name: 'p16', type: 'varchar', length: 2 }) + p16: string; - @Column({ type: 'varchar', length: 5 }) - p17: string; + @Column({ name: 'p17', type: 'varchar', length: 5 }) + p17: string; - @Column() - p18: boolean; + @Column({ name: 'p18', type: 'tinyint', width: 1 }) + p18: number; - @Column() - p19: boolean; + @Column({ name: 'p19', type: 'tinyint', width: 1 }) + p19: number; - @Column() - p20: boolean; + @Column({ name: 'p20', type: 'tinyint', width: 1 }) + p20: number; - @Column({ type: 'varchar', length: 9 }) - p21: string; + @Column({ name: 'p21', type: 'varchar', length: 9 }) + p21: string; - @Column({ type: 'varchar', length: 23 }) - p22: string; + @Column({ name: 'p22', type: 'varchar', length: 23 }) + p22: string; - @Column({ type: 'varchar', length: 8 }) - p23: string; + @Column({ name: 'p23', type: 'varchar', length: 8 }) + p23: string; - @Column({ type: 'varchar', length: 8 }) - p24: string; + @Column({ name: 'p24', type: 'varchar', length: 8 }) + p24: string; - @Column() - p25: boolean; + @Column({ name: 'p25', type: 'tinyint', width: 1 }) + p25: number; - @Column() - p26: boolean; + @Column({ name: 'p26', type: 'tinyint', width: 1 }) + p26: number; - @Column({ type: 'varchar', length: 400 }) - p27: string; + @Column({ name: 'p27', type: 'varchar', length: 400 }) + p27: string; - @Column({ type: 'varchar', length: 1 }) - p28: string; + @Column({ name: 'p28', type: 'varchar', length: 1 }) + p28: string; - @Column({ type: 'varchar', length: 1 }) - p29: string; + @Column({ name: 'p29', type: 'varchar', length: 1 }) + p29: string; - @Column({ type: 'varchar', length: 400 }) - p30: string; + @Column({ name: 'p30', type: 'varchar', length: 400 }) + p30: string; - @OneToMany(()=>Servicio,(servicio)=>servicio.cuestionarioAlumno2) - servicio:Servicio[]; + @Column({ name: 'createdAt', type: 'datetime' }) + createdAt: Date; + @OneToMany(() => Servicio, (servicio) => servicio.cuestionarioAlumno2) + servicio: Servicio[]; } diff --git a/src/main.ts b/src/main.ts index 9278ba0..e014ffe 100644 --- a/src/main.ts +++ b/src/main.ts @@ -4,9 +4,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}`); + await app.listen(process.env.APP_PORT ?? 3000); + console.log( + `Aplicación corriendo en: http://localhost:${process.env.APP_PORT ?? 3000}`, + ); } bootstrap(); diff --git a/src/programa/entities/programa.entity.ts b/src/programa/entities/programa.entity.ts index f62d010..7c15cf6 100644 --- a/src/programa/entities/programa.entity.ts +++ b/src/programa/entities/programa.entity.ts @@ -1,6 +1,13 @@ -import { Servicio } from "src/servicio/entities/servicio.entity"; -import { Usuario } from "src/usuario/entities/usuario.entity"; -import { Column, Entity, ManyToOne, OneToMany, PrimaryGeneratedColumn } from "typeorm"; +import { Servicio } from 'src/servicio/entities/servicio.entity'; +import { Usuario } from 'src/usuario/entities/usuario.entity'; +import { + Column, + Entity, + JoinColumn, + ManyToOne, + OneToMany, + PrimaryGeneratedColumn, +} from 'typeorm'; @Entity('programa') export class Programa { @@ -25,9 +32,10 @@ export class Programa { @Column({ type: 'boolean', default: true }) activo: boolean; - @ManyToOne(()=>Usuario,(usuario)=>usuario.programa) - usuario:Usuario; + @ManyToOne(() => Usuario, (usuario) => usuario.programa) + @JoinColumn({ name: 'idUsuario' }) + usuario: Usuario; - @OneToMany(()=>Servicio,(servicio)=>servicio.cuestionarioAlumno2) - servicio:Servicio[]; + @OneToMany(() => Servicio, (servicio) => servicio.cuestionarioAlumno2) + servicio: Servicio[]; } diff --git a/src/servicio/entities/servicio.entity.ts b/src/servicio/entities/servicio.entity.ts index 087cc45..0182ecf 100644 --- a/src/servicio/entities/servicio.entity.ts +++ b/src/servicio/entities/servicio.entity.ts @@ -1,88 +1,110 @@ -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"; +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, + JoinColumn, + ManyToOne, + PrimaryGeneratedColumn, +} from 'typeorm'; @Entity('servicio') export class Servicio { + @PrimaryGeneratedColumn() + idServicio: number; - @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; + @Column({ type: 'varchar', length: 3 }) + creditos: string; - @ManyToOne(()=>Usuario,(usuario)=>usuario.servicio) - usuario:Usuario + @Column({ type: 'varchar', length: 60 }) + correo: string; - @ManyToOne(()=>CuestionarioAlumno2,(cuestionarioAlumno2)=>cuestionarioAlumno2.servicio) - cuestionarioAlumno2:CuestionarioAlumno2; + @Column({ type: 'varchar', length: 15, nullable: true, default: null }) + telefono?: string; - @ManyToOne(()=>CuestionarioPrograma2,(cuestionarioPrograma2)=>cuestionarioPrograma2.servicio) - cuestionarioPrograma2:CuestionarioPrograma2; + @Column({ type: 'varchar', length: 200, nullable: true, default: null }) + direccion?: string; - @ManyToOne(()=>CuestionarioPrograma,(cuestionarioPrograma)=>cuestionarioPrograma.servicio) - cuestionarioPrograma:CuestionarioPrograma; - - @ManyToOne(()=>CuestionarioAlumno,(cuestionarioAlumno)=>cuestionarioAlumno.servicio) - cuestionarioAlumno:CuestionarioAlumno; + @Column({ type: 'date' }) + fechaInicio: Date; - @ManyToOne(()=>Status,(status)=>status.servicio) - status:Status; + @Column({ type: 'date' }) + fechaFin: Date; - @ManyToOne(()=>Programa,(programa)=>programa.servicio) - programa:Programa; + @Column({ type: 'date', nullable: true, default: null }) + fechaLiberacion?: Date; - @ManyToOne(()=>Carrera,(carrera)=>carrera.servicio) - carrera:Carrera; + @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) + @JoinColumn({ name: 'idUsuario' }) + usuario: Usuario; + + @ManyToOne( + () => CuestionarioAlumno2, + (cuestionarioAlumno2) => cuestionarioAlumno2.servicio, + ) + @JoinColumn({ name: 'idCuestionarioAlumno2' }) + cuestionarioAlumno2: CuestionarioAlumno2; + + @ManyToOne( + () => CuestionarioPrograma2, + (cuestionarioPrograma2) => cuestionarioPrograma2.servicio, + ) + @JoinColumn({ name: 'idCuestionarioPrograma2' }) + cuestionarioPrograma2: CuestionarioPrograma2; + + @ManyToOne( + () => CuestionarioPrograma, + (cuestionarioPrograma) => cuestionarioPrograma.servicio, + ) + @JoinColumn({ name: 'idCuestionarioPrograma' }) + cuestionarioPrograma: CuestionarioPrograma; + + @ManyToOne( + () => CuestionarioAlumno, + (cuestionarioAlumno) => cuestionarioAlumno.servicio, + ) + @JoinColumn({ name: 'idCuestionarioAlumno' }) + cuestionarioAlumno: CuestionarioAlumno; + + @ManyToOne(() => Status, (status) => status.servicio) + @JoinColumn({ name: 'idStatus' }) + status: Status; + + @ManyToOne(() => Programa, (programa) => programa.servicio) + @JoinColumn({ name: 'idPrograma' }) + programa: Programa; + + @ManyToOne(() => Carrera, (carrera) => carrera.servicio) + @JoinColumn({ name: 'idCarrera' }) + carrera: Carrera; } diff --git a/src/tipo-usuario/entities/tipo-usuario.entity.ts b/src/tipo-usuario/entities/tipo-usuario.entity.ts index 0ca669b..59eda57 100644 --- a/src/tipo-usuario/entities/tipo-usuario.entity.ts +++ b/src/tipo-usuario/entities/tipo-usuario.entity.ts @@ -1,16 +1,14 @@ -import { Usuario } from "src/usuario/entities/usuario.entity"; -import { Column, Entity, OneToMany, PrimaryGeneratedColumn } from "typeorm"; +import { Usuario } from 'src/usuario/entities/usuario.entity'; +import { Column, Entity, OneToMany, PrimaryGeneratedColumn } from 'typeorm'; @Entity('tipo_usuario') export class TipoUsuario { + @PrimaryGeneratedColumn() + idTipoUsuario: number; - @PrimaryGeneratedColumn() - idTipoUsuario: number; - - @Column({ type: 'varchar', length: 15 }) - tipoUsuario: string; - - @OneToMany(()=>Usuario, (usuario)=>usuario.tipoUsuario) - usuario:Usuario; + @Column({ type: 'varchar', length: 15 }) + tipoUsuario: string; + @OneToMany(() => Usuario, (usuario) => usuario.tipoUsuario) + usuario: Usuario; } diff --git a/src/tipo-usuario/tipo-usuario.module.ts b/src/tipo-usuario/tipo-usuario.module.ts index a752fba..fd78587 100644 --- a/src/tipo-usuario/tipo-usuario.module.ts +++ b/src/tipo-usuario/tipo-usuario.module.ts @@ -1,6 +1,9 @@ import { Module } from '@nestjs/common'; +import { TypeOrmModule } from '@nestjs/typeorm'; +import { TipoUsuario } from './entities/tipo-usuario.entity'; @Module({ + imports: [TypeOrmModule.forFeature([TipoUsuario])], controllers: [], providers: [], })