import { Column, Entity, JoinColumn, JoinTable, ManyToMany, ManyToOne, OneToMany, PrimaryGeneratedColumn, } from "typeorm"; import { LocalChange, MasterNotification, MasterSession, PartnerNotification, VerifyLocal, } from ".."; import { City } from "./City"; import { DiscountCodeCompany } from "./DiscountCodeCompany"; import { MasterRole } from "./MasterRole"; @Entity({ comment: "Tabla agregada para los usuarios qué son administradores de la plataforma.", }) export class Master { @PrimaryGeneratedColumn({ type: "int", comment: "Número de identificación (ID) único de cada registro.", }) id: number; @Column({ length: 30, type: "varchar", unique: true, comment: "Código único del master.", }) code: string; @Column({ type: "varchar", length: 14, nullable: true, default: null, unique: true, comment: "Número de documento del master.", }) document: string | null; @Column({ length: 50, type: "varchar", comment: "Nombre del master." }) name: string; @Column({ length: 50, type: "varchar", comment: "Apellidos del master." }) surname: string; @Column({ type: "varchar", length: 100, unique: true, comment: "Correo electrónico del master.", }) email: string; @Column({ type: "varchar", length: 12, unique: true, nullable: true, default: null, comment: "Número de celular del master.", }) phone: string | null; @ManyToOne(() => City, (city) => city.masters, { onDelete: "RESTRICT", onUpdate: "NO ACTION", }) @JoinColumn({ name: "city" }) city: City; @Column({ nullable: true, type: "varchar", length: 100, comment: "Dirección del master.", }) address: string; @Column({ type: "varchar", nullable: false, default: null, length: 255, comment: "Contraseña almacenada tipo SHA256 del master.", }) password: string | null; @Column({ length: 255, type: "varchar", unique: true, nullable: true, default: null, comment: "Guardamos el token o lo que nos retorna google cuando le damos iniciar con google", }) google_id: string | null; @Column({ type: "json", nullable: true, default: null, comment: "Campo de tipo JSON donde se guarda información necesaria para el registro.", }) profile: any | null; @Column({ type: "datetime", comment: "Fecha de creación del registro.", default: () => "CURRENT_TIMESTAMP", }) created: Date; @Column({ type: "datetime", comment: "Fecha de actualización del registro.", default: () => "CURRENT_TIMESTAMP", onUpdate: "CURRENT_TIMESTAMP", }) updated: Date; @Column({ default: 1, type: "int", width: 1, comment: "¿El master tiene acceso a la plataforma?:\r\n1. Activo: El master tiene acceso.\r\n0. Inactivo: El master no tiene acceso a la plataforma.", }) status: number; @Column({ default: 1, type: "int", width: 1, comment: "Es el estado para verificar si se envía en la papelera o no.", }) visible: number; @OneToMany( () => DiscountCodeCompany, (discountCodeCompany) => discountCodeCompany.created_by, ) discounts_code_company_created_by: DiscountCodeCompany[]; @OneToMany( () => DiscountCodeCompany, (discountCodeCompany) => discountCodeCompany.updated_by, ) discount_code_companies: DiscountCodeCompany[]; @ManyToMany(() => MasterRole, (masterRole) => masterRole.masters_roles) @JoinTable({ name: "master_assigned_role", joinColumn: { name: "master", referencedColumnName: "id", }, inverseJoinColumn: { name: "role", referencedColumnName: "id", }, }) masters_roles: MasterRole[]; @OneToMany(() => VerifyLocal, (verifyLocal) => verifyLocal.partner) verifyLocals: VerifyLocal[]; @OneToMany( () => MasterNotification, (masterNotification) => masterNotification.master, ) master_notifications: MasterNotification[]; @ManyToMany( () => MasterNotification, (masterNotification) => masterNotification.master_to_notifications, ) @JoinTable({ name: "master_to_notification", joinColumn: { name: "master", referencedColumnName: "id", }, inverseJoinColumn: { name: "master_notification", referencedColumnName: "id", }, }) masters_to_notification: MasterNotification[]; @OneToMany( () => PartnerNotification, (partner_notification) => partner_notification.master, ) masters_notification: PartnerNotification[]; @OneToMany(() => MasterSession, (MasterSession) => MasterSession.master) masters_session: MasterSession[]; @OneToMany(() => LocalChange, (localChange) => localChange.assigned_to) local_changes: LocalChange[]; }