Entidades y Realciones(Falta enrutar bien)
This commit is contained in:
@@ -1,12 +1,17 @@
|
||||
import { Entity, Column, PrimaryColumn, ManyToOne } from "typeorm";
|
||||
|
||||
import { Entity, PrimaryColumn, Column, ManyToOne, OneToMany, JoinColumn } from 'typeorm';
|
||||
import { Edificio } from './edificio.entity';
|
||||
import { Adscripcion } from './adscripcion.entity';
|
||||
import { Categoria } from './categoria.entity';
|
||||
import { DatosAcademicos } from './datos_academicos.entity';
|
||||
import { LineasInvestigacion } from './lineas_investigacion.entity';
|
||||
import { ProyectosAcademicos } from './proyectos_academicos.entity';
|
||||
|
||||
@Entity()
|
||||
export class Profesor {
|
||||
@PrimaryColumn({ type: 'int', length:11, nullable: false })
|
||||
@PrimaryColumn({ type: 'int', length: 11, nullable: false })
|
||||
id_profesor: number;
|
||||
|
||||
@Column({ type: 'int', length:11, nullable: false })
|
||||
@Column({ type: 'int', length: 11, nullable: false })
|
||||
id_usuario: number;
|
||||
|
||||
@Column({ type: 'varchar', length: 10, nullable: true })
|
||||
@@ -63,4 +68,24 @@ export class Profesor {
|
||||
@Column({ type: 'timestamp', nullable: false, default: () => 'CURRENT_TIMESTAMP', onUpdate: 'CURRENT_TIMESTAMP' })
|
||||
fecha_actualizacion: Date;
|
||||
|
||||
@ManyToOne(() => Edificio, edificio => edificio.profesores)
|
||||
@JoinColumn({ name: 'id_edificio' })
|
||||
edificio: Edificio;
|
||||
|
||||
@ManyToOne(() => Adscripcion, adscripcion => adscripcion.profesores)
|
||||
@JoinColumn({ name: 'id_adscripcion' })
|
||||
adscripcion: Adscripcion;
|
||||
|
||||
@ManyToOne(() => Categoria, categoria => categoria.profesores)
|
||||
@JoinColumn({ name: 'id_categoria' })
|
||||
categoria: Categoria;
|
||||
|
||||
@OneToMany(() => DatosAcademicos, datosAcademicos => DatosAcademicos.profesor)
|
||||
datosAcademicos: DatosAcademicos[];
|
||||
|
||||
@OneToMany(() => LineasInvestigacion, lineasInvestigacion => LineasInvestigacion.profesor)
|
||||
lineasInvestigacion: LineasInvestigacion[];
|
||||
|
||||
@OneToMany(() => ProyectosAcademicos, proyectosAcademicos => ProyectosAcademicos.profesor)
|
||||
proyectosAcademicos: ProyectosAcademicos[];
|
||||
}
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
import { Entity, PrimaryColumn, Column, OneToMany } from 'typeorm';
|
||||
import { Profesor } from './profesor.entity';
|
||||
|
||||
@Entity({ name: 'adscripcion' })
|
||||
@Entity()
|
||||
export class Adscripcion {
|
||||
|
||||
@PrimaryColumn({ type: 'int', length: 11, nullable: false })
|
||||
id_adscripcion: number;
|
||||
|
||||
@Column({ type: 'varchar', length: 150, nullable: false })
|
||||
adscripcion: string;
|
||||
|
||||
@OneToMany(() => Profesor, profesor => Profesor.adscripcion)
|
||||
profesores: Profesor[];
|
||||
}
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
import { Entity, PrimaryColumn, Column } from 'typeorm';
|
||||
import { Entity, PrimaryColumn, Column, OneToMany } from 'typeorm';
|
||||
import { Profesor } from './profesor.entity';
|
||||
|
||||
@Entity()
|
||||
export class Categoria {
|
||||
|
||||
@PrimaryColumn({ type: 'int', length: 11, nullable: false })
|
||||
id_categoria: number;
|
||||
|
||||
@Column({ type: 'varchar', length: 256, nullable: false })
|
||||
categoria: string;
|
||||
|
||||
@OneToMany(() => Profesor, profesor => Profesor.categoria)
|
||||
profesores: Profesor[];
|
||||
}
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import { Entity,PrimaryColumn, Column } from 'typeorm';
|
||||
import { Entity, PrimaryColumn, Column, ManyToOne, JoinColumn } from 'typeorm';
|
||||
import { Profesor } from './profesor.entity';
|
||||
|
||||
@Entity({ name: 'datos_academicos' })
|
||||
export class DatosAcademicos {
|
||||
|
||||
@PrimaryColumn({ type: 'int', length:11, nullable:false })
|
||||
@PrimaryColumn({ type: 'int', length: 11, nullable: false })
|
||||
id_datos: number;
|
||||
|
||||
@Column({ type: 'int', nullable: false })
|
||||
@@ -12,7 +13,10 @@ export class DatosAcademicos {
|
||||
@Column({ type: 'varchar', length: 30, nullable: true })
|
||||
grado_maximo: string;
|
||||
|
||||
@Column({ type: 'varchar', length: 260, nullable: true})
|
||||
@Column({ type: 'varchar', length: 260, nullable: true })
|
||||
grados_obtenidos: string;
|
||||
|
||||
@ManyToOne(() => Profesor, profesor => profesor.datosAcademicos)
|
||||
@JoinColumn({ name: 'id_profesor' })
|
||||
profesor: Profesor;
|
||||
}
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
import { Entity, PrimaryColumn, Column } from 'typeorm';
|
||||
import { Entity, PrimaryColumn, Column, OneToMany } from 'typeorm';
|
||||
import { Profesor } from './profesor.entity';
|
||||
|
||||
@Entity()
|
||||
export class Edificio {
|
||||
|
||||
@PrimaryColumn({ type: 'int', length:11, nullable: false })
|
||||
@PrimaryColumn({ type: 'int', length: 11, nullable: false })
|
||||
id_edificio: number;
|
||||
|
||||
@Column({ type: 'varchar', length: 256, nullable: false })
|
||||
edificio: string;
|
||||
|
||||
@OneToMany(() => Profesor, profesor => Profesor.edificio)
|
||||
profesores: Profesor[];
|
||||
}
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import { Entity,PrimaryColumn, Column} from 'typeorm'
|
||||
import { Entity, PrimaryColumn, Column, ManyToOne, JoinColumn } from 'typeorm';
|
||||
import { Profesor } from './profesor.entity';
|
||||
|
||||
@Entity({ name: 'lineas_investigacion' })
|
||||
export class LineasInvestigacion {
|
||||
|
||||
@PrimaryColumn({ type: 'int', length:11, nullable: false })
|
||||
@PrimaryColumn({ type: 'int', length: 11, nullable: false })
|
||||
id_linea_inv: number;
|
||||
|
||||
@Column({ type: 'int', nullable: false })
|
||||
@@ -15,4 +16,7 @@ export class LineasInvestigacion {
|
||||
@Column({ type: 'varchar', length: 255, nullable: true })
|
||||
lineas_inv_html: string;
|
||||
|
||||
@ManyToOne(() => Profesor, profesor => profesor.lineasInvestigacion)
|
||||
@JoinColumn({ name: 'id_profesor' })
|
||||
profesor: Profesor;
|
||||
}
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
import { Entity,PrimaryColumn, Column } from 'typeorm';
|
||||
|
||||
@Entity({ name: 'proyectos_academicos' })
|
||||
export class ProyectosAcademicos {
|
||||
|
||||
@PrimaryColumn({ type: 'int', length:11, nullable: false })
|
||||
id_proyecto: number;
|
||||
|
||||
@Column({ type: 'int', nullable: false })
|
||||
id_profesor: number;
|
||||
|
||||
@Column({ type: 'varchar', length: 255, nullable: true })
|
||||
proyecto: string;
|
||||
|
||||
@Column({ type: 'varchar', length: 255, nullable: true })
|
||||
proyecto_html: string;
|
||||
}
|
||||
@@ -1,14 +1,22 @@
|
||||
import {Entity,Column,PrimaryColumn} from "typeorm";
|
||||
import { Entity, PrimaryColumn, Column, ManyToOne, JoinColumn } from 'typeorm';
|
||||
import { Profesor } from './profesor.entity';
|
||||
|
||||
@Entity()
|
||||
export class proyectos_academicos{
|
||||
@Entity({ name: 'proyectos_academicos' })
|
||||
export class ProyectosAcademicos {
|
||||
|
||||
@PrimaryColumn()
|
||||
id_proyectos:number
|
||||
@PrimaryColumn({ type: 'int', length: 11, nullable: false })
|
||||
id_proyecto: number;
|
||||
|
||||
@Column()
|
||||
id_profesor:number
|
||||
@Column({ type: 'int', nullable: false })
|
||||
id_profesor: number;
|
||||
|
||||
@Column()
|
||||
proyectos: string
|
||||
}
|
||||
@Column({ type: 'varchar', length: 255, nullable: true })
|
||||
proyecto: string;
|
||||
|
||||
@Column({ type: 'varchar', length: 255, nullable: true })
|
||||
proyecto_html: string;
|
||||
|
||||
@ManyToOne(() => Profesor, profesor => profesor.proyectosAcademicos)
|
||||
@JoinColumn({ name: 'id_profesor' })
|
||||
profesor: Profesor;
|
||||
}
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
import { Entity,PrimaryColumn, Column } from 'typeorm';
|
||||
import { Entity, PrimaryColumn, Column, OneToMany } from 'typeorm';
|
||||
import { User } from './user.entity';
|
||||
|
||||
@Entity()
|
||||
@Entity({ name: 'tipo_usuario' })
|
||||
export class TipoUsuario {
|
||||
|
||||
@PrimaryColumn({ type: 'int', length:11, nullable: false })
|
||||
|
||||
@PrimaryColumn({ type: 'int', length: 11, nullable: false })
|
||||
id_tipo_usuario: number;
|
||||
|
||||
@Column({ type: 'varchar', length: 30, nullable: false })
|
||||
tipo_usuario: string;
|
||||
|
||||
@OneToMany(() => User, user => User.tipoUsuario)
|
||||
users: User[];
|
||||
}
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import { Entity,PrimaryColumn, Column,} from 'typeorm';
|
||||
import { Entity, PrimaryColumn, Column, ManyToOne, JoinColumn } from 'typeorm';
|
||||
import { TipoUsuario } from './tipo_usuario.entity';
|
||||
|
||||
@Entity({ name: 'usuario' })
|
||||
export class User {
|
||||
|
||||
@PrimaryColumn({ type: 'int', length:11, nullable:false })
|
||||
@PrimaryColumn({ type: 'int', length: 11, nullable: false })
|
||||
id_usuario: number;
|
||||
|
||||
@Column({ type: 'int', nullable: false })
|
||||
@@ -27,4 +28,7 @@ export class User {
|
||||
@Column({ type: 'datetime', nullable: true })
|
||||
lastlog: Date;
|
||||
|
||||
@ManyToOne(() => TipoUsuario, tipoUsuario => tipoUsuario.users)
|
||||
@JoinColumn({ name: 'id_tipo_usuario' })
|
||||
tipoUsuario: TipoUsuario;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user