fixed foreign key and delete carrera
This commit is contained in:
@@ -1,19 +1,17 @@
|
||||
import { IsBoolean, IsEmpty, IsNotEmpty, IsNumber, IsString, Length,} from "class-validator";
|
||||
import { IsBoolean, IsOptional, IsNotEmpty, IsNumber, IsString, Length,} from "class-validator";
|
||||
|
||||
export class profesorDto{
|
||||
|
||||
@IsNumber()
|
||||
@IsNotEmpty()
|
||||
@Length(11)
|
||||
id_profesor: number;
|
||||
|
||||
@IsNumber()
|
||||
@IsNotEmpty()
|
||||
@Length(11)
|
||||
id_usuario: number;
|
||||
|
||||
@IsString()
|
||||
@IsEmpty()
|
||||
@IsOptional()
|
||||
@Length(10)
|
||||
num_trabajador: string;
|
||||
|
||||
@@ -23,62 +21,59 @@ export class profesorDto{
|
||||
nombre: string;
|
||||
|
||||
@IsString()
|
||||
@IsEmpty()
|
||||
@IsOptional()
|
||||
@Length(10)
|
||||
rfc: string;
|
||||
|
||||
@IsString()
|
||||
@IsEmpty()
|
||||
@IsOptional()
|
||||
@Length(3)
|
||||
homoclave: string;
|
||||
|
||||
@IsString()
|
||||
@IsEmpty()
|
||||
@IsOptional()
|
||||
@Length(13)
|
||||
tel_oficina: string;
|
||||
|
||||
@IsString()
|
||||
@IsEmpty()
|
||||
@IsOptional()
|
||||
@Length(10)
|
||||
extension: string;
|
||||
|
||||
@IsString()
|
||||
@IsEmpty()
|
||||
@IsOptional()
|
||||
@Length(13)
|
||||
tel_personal: string;
|
||||
|
||||
@IsString()
|
||||
@IsEmpty()
|
||||
@IsOptional()
|
||||
@Length(65)
|
||||
correo_pcp: string;
|
||||
|
||||
@IsString()
|
||||
@IsEmpty()
|
||||
@IsOptional()
|
||||
@Length(65)
|
||||
correo_per: string;
|
||||
|
||||
@IsNumber()
|
||||
@IsEmpty()
|
||||
@Length(11)
|
||||
@IsOptional()
|
||||
id_adscripcion: number;
|
||||
|
||||
@IsNumber()
|
||||
@IsEmpty()
|
||||
@Length(11)
|
||||
@IsOptional()
|
||||
id_categoria: number;
|
||||
|
||||
@IsNumber()
|
||||
@IsEmpty()
|
||||
@Length(11)
|
||||
@IsOptional()
|
||||
id_edificio: number;
|
||||
|
||||
@IsString()
|
||||
@IsEmpty()
|
||||
@IsOptional()
|
||||
@Length(256)
|
||||
ubicacion: string;
|
||||
|
||||
@IsString()
|
||||
@IsEmpty()
|
||||
@IsOptional()
|
||||
@Length(150)
|
||||
fotografia: string;
|
||||
|
||||
|
||||
@@ -12,7 +12,6 @@ import { Categoria } from '../../categoria/entities/categoria.entity';
|
||||
import { DatosAcademicos } from '../../datos_academicos/entities/datos_academicos.entity';
|
||||
import { LineasInvestigacion } from '../../lineas_investigacion/entities/lineas_investigacion.entity';
|
||||
import { ProyectosAcademicos } from '../../proyectos_academicos/entities/proyectos_academicos.entity';
|
||||
import { AsignaturaCarreraProfesor } from '../../asignatura_carrera_profesor/entities/asignatura_carrera_profesor.entity';
|
||||
|
||||
@Entity()
|
||||
export class Profesor {
|
||||
@@ -71,8 +70,9 @@ export class Profesor {
|
||||
mostrar: boolean;
|
||||
|
||||
@Column({
|
||||
type: 'datetime',
|
||||
type: 'timestamp',
|
||||
nullable: false,
|
||||
default: () => 'CURRENT_TIMESTAMP',
|
||||
})
|
||||
fecha_alta: Date;
|
||||
|
||||
@@ -114,9 +114,4 @@ export class Profesor {
|
||||
)
|
||||
proyectosAcademicos: ProyectosAcademicos[];
|
||||
|
||||
@OneToMany(
|
||||
() => AsignaturaCarreraProfesor,
|
||||
(acp) => acp.profesor,
|
||||
)
|
||||
asignaturaCarreraProfesores: AsignaturaCarreraProfesor[];
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ export class ProfesorController {
|
||||
constructor(private profesorService: ProfesorService) {}
|
||||
|
||||
@Post()
|
||||
async postRegister(@Body() data: profesorDto) {
|
||||
async register(@Body() data: profesorDto) {
|
||||
return this.profesorService.register(data);
|
||||
}
|
||||
|
||||
|
||||
@@ -7,9 +7,6 @@ import { TypeOrmModule } from '@nestjs/typeorm';
|
||||
import { UsersModule } from './users/users.module';
|
||||
import { User } from './users/entities/user.entity';
|
||||
import { Adscripcion } from './adscripcion/entities/adscripcion.entity';
|
||||
import { Asignatura } from './asignatura/entities/asignatura.entity';
|
||||
import { AsignaturaCarreraProfesor } from './asignatura_carrera_profesor/entities/asignatura_carrera_profesor.entity';
|
||||
import { Carrera } from './carrera/entities/carrera.entity';
|
||||
import { Categoria } from './categoria/entities/categoria.entity';
|
||||
import { DatosAcademicos } from './datos_academicos/entities/datos_academicos.entity';
|
||||
import { Edificio } from './edificio/entities/edificio.entity';
|
||||
@@ -41,9 +38,6 @@ import { Profesor } from './Profesor/entities/profesor.entity';
|
||||
User,
|
||||
Profesor,
|
||||
Adscripcion,
|
||||
Asignatura,
|
||||
AsignaturaCarreraProfesor,
|
||||
Carrera,
|
||||
Categoria,
|
||||
DatosAcademicos,
|
||||
Edificio,
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
import { Entity, PrimaryGeneratedColumn, Column, OneToMany } from 'typeorm';
|
||||
import { AsignaturaCarreraProfesor } from "../../asignatura_carrera_profesor/entities/asignatura_carrera_profesor.entity";
|
||||
|
||||
@Entity()
|
||||
export class Asignatura {
|
||||
|
||||
@PrimaryGeneratedColumn()
|
||||
id_asignatura: number;
|
||||
|
||||
@Column({ type: 'varchar', length: 50, nullable: false })
|
||||
materia: string;
|
||||
|
||||
@OneToMany(() => AsignaturaCarreraProfesor, (acp) => acp.asignatura)
|
||||
asignaturaCarreraProfesores: AsignaturaCarreraProfesor[];
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
import { Entity, PrimaryColumn, Column, ManyToOne, JoinColumn } from 'typeorm';
|
||||
import { Profesor } from "../../Profesor/entities/profesor.entity";
|
||||
import { Asignatura } from "../../asignatura/entities/asignatura.entity";
|
||||
import { Carrera } from 'src/carrera/entities/carrera.entity';
|
||||
|
||||
@Entity()
|
||||
export class AsignaturaCarreraProfesor {
|
||||
@PrimaryColumn({ type: 'int', nullable: false })
|
||||
id_profesor: number;
|
||||
|
||||
@PrimaryColumn({ type: 'int', nullable: false })
|
||||
id_carrera: number;
|
||||
|
||||
@PrimaryColumn({ type: 'int', nullable: false })
|
||||
id_asignatura: number;
|
||||
|
||||
@Column({ type: 'varchar', length: 150, nullable: false })
|
||||
semestre: string;
|
||||
|
||||
@Column({ type: 'varchar', length: 150, nullable: false })
|
||||
periodo: string;
|
||||
|
||||
@ManyToOne(() => Profesor, profesor => profesor.asignaturaCarreraProfesores)
|
||||
@JoinColumn({ name: 'id_profesor' })
|
||||
profesor: Profesor;
|
||||
|
||||
@ManyToOne(() => Carrera, carrera => carrera.asignaturaCarreraProfesores)
|
||||
@JoinColumn({ name: 'id_carrera' })
|
||||
carrera: Carrera;
|
||||
|
||||
@ManyToOne(() => Asignatura, asignatura => asignatura.asignaturaCarreraProfesores)
|
||||
@JoinColumn({ name: 'id_asignatura' })
|
||||
asignatura: Asignatura;
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
import { Entity, PrimaryGeneratedColumn, Column, OneToMany } from 'typeorm';
|
||||
import { AsignaturaCarreraProfesor } from "../../asignatura_carrera_profesor/entities/asignatura_carrera_profesor.entity";
|
||||
|
||||
@Entity()
|
||||
export class Carrera {
|
||||
|
||||
@PrimaryGeneratedColumn()
|
||||
id_carrera: number;
|
||||
|
||||
@Column({ type: 'varchar', length: 150, nullable: false })
|
||||
nombre: string;
|
||||
|
||||
@OneToMany(() => AsignaturaCarreraProfesor, asi => asi.carrera)
|
||||
asignaturaCarreraProfesores: AsignaturaCarreraProfesor[];
|
||||
}
|
||||
@@ -1,5 +1,4 @@
|
||||
import { Entity, PrimaryColumn, Column, OneToMany } from 'typeorm';
|
||||
import { Profesor } from '../../Profesor/entities/profesor.entity';
|
||||
|
||||
@Entity()
|
||||
export class Categoria {
|
||||
@@ -9,6 +8,6 @@ export class Categoria {
|
||||
@Column({ type: 'varchar', length: 256, nullable: false })
|
||||
categoria: string;
|
||||
|
||||
@OneToMany(() => Profesor, (profesor) => profesor.categoria)
|
||||
profesores: Profesor[];
|
||||
@OneToMany(() => Categoria, (categoria) => categoria.profesores)
|
||||
profesores: Categoria[];
|
||||
}
|
||||
|
||||
@@ -17,5 +17,5 @@ export class DatosAcademicos {
|
||||
|
||||
@ManyToOne(() => Profesor, (profesor) => profesor.datosAcademicos)
|
||||
@JoinColumn({ name: 'id_profesor' })
|
||||
profesor: Profesor;
|
||||
profesor: Profesor[];
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { Entity, PrimaryColumn, Column, OneToMany } from 'typeorm';
|
||||
import { Profesor } from "../../Profesor/entities/profesor.entity";
|
||||
|
||||
@Entity()
|
||||
export class Edificio {
|
||||
@@ -9,6 +8,6 @@ export class Edificio {
|
||||
@Column({ type: 'varchar', length: 256, nullable: false })
|
||||
edificio: string;
|
||||
|
||||
@OneToMany(() => Profesor, profesor => profesor.edificio)
|
||||
profesores: Profesor[];
|
||||
@OneToMany(() => Edificio, edificio => edificio.profesores)
|
||||
profesores: Edificio[];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user