import { Column, Entity, JoinColumn, JoinTable, ManyToMany, ManyToOne, OneToMany, PrimaryGeneratedColumn, } from "typeorm"; import { Category, Gallery, LocalChange, LocalReserve, LocalReserveStatus, LocalTable, LocalTableReservePayment, LocalTableZone, MasterNotification, PartnerSession, PendingModification, Product, RequestInvoice, RequestLocal, RequestLocalHistory, RequestLocalPayment, RequestPrint, VerifyLocal, } from ".."; import { City } from "./City"; import { Company } from "./Company"; import { DiscountCodeUser } from "./DiscountCodeUser"; import { Local } from "./Local"; import { PartnerNotification } from "./PartnerNotification"; import { PartnerRole } from "./PartnerRole"; @Entity({ comment: "Tabla agregada para los usuarios qué quieran registrar su local o empresa de comida rápida en la plataforma.\r\n\r\nEste usuario es independiente a los usuarios de la tabla `user` ya que tiene diferentes plataformas.\r\n\r\nTambién van a estar los usuarios qué el administrador/dueño desee agregar como empleados/colaboradores.", }) export class Partner { @PrimaryGeneratedColumn({ type: "int", comment: "Número de identificación (ID) único de cada registro.", }) id: number; @ManyToOne(() => Company, (company) => company.partners_company, { onDelete: "CASCADE", onUpdate: "NO ACTION", nullable: true, }) @JoinColumn({ name: "company" }) company: Company | null; @Column({ length: 30, type: "varchar", unique: true, comment: "Código único del partner.", }) code: string; @Column({ length: 14, nullable: true, type: "varchar", default: null, unique: true, comment: "Número de documento del partner.", }) document: string | null; @Column({ length: 50, type: "varchar", comment: "Nombre del partner." }) name: string; @Column({ length: 50, type: "varchar", comment: "Apellidos del partner." }) surname: string; @Column({ length: 100, unique: true, type: "varchar", comment: "Correo electrónico del partner.", }) email: string; @Column({ length: 12, unique: true, type: "varchar", nullable: true, default: null, comment: "Número de celular del partner.", }) phone: string | null; @ManyToOne(() => City, (city) => city.partners, { onDelete: "RESTRICT", onUpdate: "NO ACTION", }) @JoinColumn({ name: "city" }) city: City; @Column({ nullable: true, default: null, type: "varchar", length: 100, comment: "Dirección del partner.", }) address: string | null; @Column({ length: 255, type: "varchar", nullable: true, default: null, comment: "Contraseña almacenada tipo SHA256 del partner.", }) 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({ default: 0, type: "int", width: 1, comment: "En este campo sabemos sí el usuario que está en la tabla es dueño de una empresa/company en la plataforma.", }) owner: number; @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 partner tiene acceso a la plataforma?:\r\n1. Activo: El partner tiene acceso.\r\n0. Inactivo: El partner 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(() => Company, (company) => company.partner) companies: Company[]; @OneToMany( () => DiscountCodeUser, (discountCodeUser) => discountCodeUser.created_by, ) discounts_code_user_created_by: DiscountCodeUser[]; @OneToMany( () => DiscountCodeUser, (discountCodeUser) => discountCodeUser.updated_by, ) discount_code_partners: DiscountCodeUser[]; @OneToMany(() => Local, (local) => local.updated_by) locals: Local[]; @ManyToMany(() => Local, (local) => local.locals_partners) @JoinTable({ name: "local_partner", joinColumn: { name: "partner", referencedColumnName: "id", }, inverseJoinColumn: { name: "local", referencedColumnName: "id", }, }) locals_partner: Local[]; @ManyToMany(() => PartnerRole, (partnerRole) => partnerRole.partners_roles) @JoinTable({ name: "partner_assigned_role", joinColumn: { name: "partner", referencedColumnName: "id", }, inverseJoinColumn: { name: "role", referencedColumnName: "id", }, }) partners_roles: PartnerRole[]; @OneToMany( () => PartnerNotification, (partnerNotification) => partnerNotification.partner, ) partners_notification: PartnerNotification[]; @OneToMany(() => VerifyLocal, (verifyLocal) => verifyLocal.partner) verifyLocals: VerifyLocal[]; @ManyToMany( () => PartnerNotification, (partnerNotification) => partnerNotification.partner_to_notifications, ) @JoinTable({ name: "partner_to_notification", joinColumn: { name: "partner", referencedColumnName: "id", }, inverseJoinColumn: { name: "partner_notification", referencedColumnName: "id", }, }) partners_to_notification: PartnerNotification[]; @OneToMany( () => MasterNotification, (master_notification) => master_notification.master, ) partner_notifications: MasterNotification[]; @OneToMany(() => Product, (product) => product.updated_by) partners_update_by: Product[]; @OneToMany(() => Product, (product) => product.created_by) partners_created_by: Product[]; @OneToMany(() => Category, (category) => category.updated_by) partners_category_update_by: Category[]; @OneToMany(() => Category, (category) => category.created_by) partners_category_created_by: Category[]; @OneToMany(() => PartnerSession, (partnerSession) => partnerSession.partner) partners_session: PartnerSession[]; @OneToMany( () => RequestLocalHistory, (requestLocalHistory) => requestLocalHistory.updated_by, ) updated_by_history: RequestLocalHistory[]; @OneToMany( () => RequestLocalPayment, (requestLocalPayment) => requestLocalPayment.partner, ) requests_local_payment: RequestLocalPayment[]; @OneToMany(() => RequestPrint, (requestPrint) => requestPrint.partner) partner_prints: RequestPrint[]; @OneToMany(() => RequestLocal, (requestLocal) => requestLocal.partner) partner_request_locals: RequestLocal[]; @OneToMany( () => LocalTableZone, (localTableZone) => localTableZone.updated_by, ) local_table_zones: LocalTableZone[]; @OneToMany(() => LocalTable, (localTable) => localTable.updated_by) local_tables: LocalTable[]; @OneToMany( () => LocalTableReservePayment, (LocalTableReservePayment) => LocalTableReservePayment.partner, ) local_table_reserve_payments: LocalTableReservePayment[]; @OneToMany(() => LocalReserve, (localReserve) => localReserve.partner) local_reserves: LocalReserve[]; @OneToMany( () => LocalReserveStatus, (localReserveStatus) => localReserveStatus.updated_by, ) local_reserve_status: LocalReserveStatus[]; @OneToMany( () => RequestInvoice, (RequestInvoice) => RequestInvoice.updated_by, ) request_invoices: RequestInvoice[]; @OneToMany(() => Gallery, (gallery) => gallery.created_by) galleries: Gallery[]; @OneToMany(() => LocalChange, (localChange) => localChange.created_by) local_changes: LocalChange[]; @OneToMany(() => Local, (local) => local.created_by) created_by_locals: Local[]; @OneToMany( () => PendingModification, (pendingModification) => pendingModification.requested_by, ) created_by_pending_modifications: PendingModification[]; }