201 lines
4.9 KiB
TypeScript
201 lines
4.9 KiB
TypeScript
import { Entity, PrimaryGeneratedColumn, Column, ManyToOne, OneToMany, JoinColumn, PrimaryColumn } from 'typeorm';
|
|
|
|
@Entity({ name: 'origen' })
|
|
export class Origen {
|
|
@PrimaryGeneratedColumn({ name: 'id_origen', type: 'int' })
|
|
id_origen: number;
|
|
|
|
@Column({ type: 'varchar', length: 30 })
|
|
origen: string;
|
|
|
|
@OneToMany(() => Movimiento, movimiento => movimiento.origen)
|
|
movimientos: Movimiento[];
|
|
|
|
@OneToMany(() => UsuariosDelSistema, uds => uds.origen)
|
|
usuariosDelSistema: UsuariosDelSistema[];
|
|
}
|
|
|
|
@Entity({ name: 'genero' })
|
|
export class Genero {
|
|
@PrimaryGeneratedColumn({ name: 'id_genero', type: 'int', })
|
|
id_genero: number;
|
|
|
|
@Column({ type: 'varchar', length: 20, nullable: true })
|
|
genero: string;
|
|
|
|
@OneToMany(() => Usuario, usuario => usuario.genero)
|
|
usuarios: Usuario[];
|
|
}
|
|
|
|
@Entity({ name: 'carrera' })
|
|
export class Carrera {
|
|
@PrimaryGeneratedColumn({ name: 'id_carrera', type: 'int' })
|
|
id_carrera: number;
|
|
|
|
@Column({ type: 'varchar', length: 100 })
|
|
carrera: string;
|
|
|
|
@Column({ type: 'varchar', length: 6 })
|
|
clave: string;
|
|
|
|
@OneToMany(() => CarreraUsuario, cu => cu.carrera)
|
|
carreraUsuarios: CarreraUsuario[];
|
|
}
|
|
|
|
@Entity({ name: 'usuario' })
|
|
export class Usuario {
|
|
@PrimaryGeneratedColumn({ name: 'id_usuario', type: 'int' })
|
|
id_usuario: number;
|
|
|
|
@Column({
|
|
type: 'varchar',
|
|
length: 9,
|
|
unique: true,
|
|
nullable: true,
|
|
default: null,
|
|
})
|
|
num_cuenta: string;
|
|
|
|
@Column({ type: 'varchar', length: 60 })
|
|
nombre: string;
|
|
|
|
@Column({ name: 'a_paterno', type: 'varchar', length: 60 })
|
|
a_paterno: string;
|
|
|
|
@Column({ name: 'a_materno', type: 'varchar', length: 60 })
|
|
a_materno: string;
|
|
|
|
@Column({
|
|
type: 'varchar',
|
|
length: 15,
|
|
nullable: true,
|
|
default: null,
|
|
})
|
|
rfc: string | null;
|
|
|
|
@Column({ name: 'fecha_nacimiento', type: 'varchar', nullable: true, length: 8 })
|
|
fecha_nacimiento: string | null;
|
|
|
|
@Column({ type: 'int', nullable: true, })
|
|
generacion: number | null;
|
|
|
|
@ManyToOne(() => Genero, genero => genero.usuarios, { nullable: true })
|
|
@JoinColumn({ name: 'id_genero' })
|
|
genero: Genero | null;
|
|
|
|
|
|
@OneToMany(() => CarreraUsuario, cu => cu.usuario)
|
|
carreraUsuarios: CarreraUsuario[];
|
|
|
|
@OneToMany(() => UsuarioTipoUsuario, utu => utu.usuario)
|
|
usuarioTipos: UsuarioTipoUsuario[];
|
|
}
|
|
|
|
@Entity({ name: 'usuariosDelSistema' })
|
|
export class UsuariosDelSistema {
|
|
@PrimaryGeneratedColumn({ name: 'id_usuario', type: 'int' })
|
|
id_usuario: string;
|
|
|
|
@Column({
|
|
type: 'varchar',
|
|
length: 100, // ajusta longitud según tu necesidad
|
|
unique: true,
|
|
nullable: true,
|
|
default: null,
|
|
})
|
|
correo: string | null;
|
|
|
|
@Column({ type: 'varchar', length: 60 })
|
|
contraseña: string;
|
|
|
|
@ManyToOne(() => Origen, origen => origen.usuariosDelSistema)
|
|
@JoinColumn({ name: 'id_origen' })
|
|
origen: Origen;
|
|
}
|
|
|
|
@Entity({ name: 'carrera_usuario' })
|
|
export class CarreraUsuario {
|
|
@PrimaryGeneratedColumn({ name: 'id_carrera_usuario', type: 'int' })
|
|
id_carrera_usuario: number;
|
|
|
|
@ManyToOne(() => Carrera, carrera => carrera.carreraUsuarios)
|
|
@JoinColumn({ name: 'id_carrera' })
|
|
carrera: Carrera;
|
|
|
|
@ManyToOne(() => Usuario, usuario => usuario.carreraUsuarios)
|
|
@JoinColumn({ name: 'id_usuario' })
|
|
usuario: Usuario;
|
|
}
|
|
|
|
@Entity({ name: 'equipo' })
|
|
export class Equipo {
|
|
@PrimaryGeneratedColumn({ name: 'id_equipo', type: 'int' })
|
|
id_equipo: number;
|
|
|
|
@Column({ type: 'varchar', length: 10 })
|
|
equipo: string;
|
|
|
|
@Column({ name: 'numero_serie', type: 'varchar', length: 30 })
|
|
numero_serie: string;
|
|
}
|
|
|
|
@Entity({ name: 'tipo_usuario' })
|
|
export class TipoUsuario {
|
|
@PrimaryGeneratedColumn({ name: 'id_tipo_usuario', type: 'int' })
|
|
id_tipo_usuario: number;
|
|
|
|
@Column({ name: 'tipo_usuario', type: 'varchar', length: 20 })
|
|
tipo_usuario: string;
|
|
|
|
@OneToMany(() => UsuarioTipoUsuario, utu => utu.tipoUsuario)
|
|
usuariosTipos: UsuarioTipoUsuario[];
|
|
}
|
|
|
|
@Entity({ name: 'usuario_tipo_usuario' })
|
|
export class UsuarioTipoUsuario {
|
|
@PrimaryGeneratedColumn({ name: 'id_user_tipo_usuario', type: 'int' })
|
|
id_user_tipo_usuario: number;
|
|
|
|
@ManyToOne(() => TipoUsuario, tipo => tipo.usuariosTipos)
|
|
@JoinColumn({ name: 'id_tipo_usuario' })
|
|
tipoUsuario: TipoUsuario;
|
|
|
|
@ManyToOne(() => Usuario, usuario => usuario.usuarioTipos)
|
|
@JoinColumn({ name: 'id_usuario' })
|
|
usuario: Usuario;
|
|
}
|
|
|
|
@Entity({ name: 'movimiento' })
|
|
export class Movimiento {
|
|
@PrimaryGeneratedColumn({ name: 'id_mov', type: 'int' })
|
|
id_mov: number;
|
|
|
|
@Column({ name: 'fecha_mov', type: 'datetime' })
|
|
fecha_mov: Date;
|
|
|
|
@Column({ type: 'varchar', length: 100 })
|
|
status: string;
|
|
|
|
@Column({
|
|
type: 'varchar',
|
|
length: 200,
|
|
nullable: true, // permite NULL
|
|
})
|
|
observaciones?: string;
|
|
|
|
@Column({ type: 'bit' })
|
|
flag: boolean;
|
|
|
|
@Column({
|
|
type: 'varchar',
|
|
length: 200,
|
|
nullable: true, // permite NULL
|
|
})
|
|
reporte?: string;
|
|
|
|
|
|
@ManyToOne(() => Origen, origen => origen.movimientos)
|
|
@JoinColumn({ name: 'id_origen' })
|
|
origen: Origen;
|
|
}
|