erp-mecanicas-diesel-backen.../src/modules/parts-management/entities/part-category.entity.ts
rckrdmrd 8ed7d24e96 Migración desde erp-mecanicas-diesel/backend - Estándar multi-repo v2
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-16 08:11:24 -06:00

56 lines
1.3 KiB
TypeScript

/**
* Part Category Entity
* Mecánicas Diesel - ERP Suite
*
* Represents part categories with hierarchical structure.
*/
import {
Entity,
PrimaryGeneratedColumn,
Column,
CreateDateColumn,
UpdateDateColumn,
ManyToOne,
OneToMany,
JoinColumn,
Index,
} from 'typeorm';
@Entity({ name: 'part_categories', schema: 'parts_management' })
@Index('idx_part_categories_tenant', ['tenantId'])
@Index('idx_part_categories_parent', ['parentId'])
export class PartCategory {
@PrimaryGeneratedColumn('uuid')
id: string;
@Column({ name: 'tenant_id', type: 'uuid' })
tenantId: string;
@Column({ type: 'varchar', length: 100 })
name: string;
@Column({ type: 'varchar', length: 300, nullable: true })
description?: string;
@Column({ name: 'parent_id', type: 'uuid', nullable: true })
parentId?: string;
@Column({ name: 'sort_order', type: 'integer', default: 0 })
sortOrder: number;
@CreateDateColumn({ name: 'created_at', type: 'timestamptz' })
createdAt: Date;
@UpdateDateColumn({ name: 'updated_at', type: 'timestamptz' })
updatedAt: Date;
// Relations
@ManyToOne(() => PartCategory, category => category.children, { nullable: true })
@JoinColumn({ name: 'parent_id' })
parent?: PartCategory;
@OneToMany(() => PartCategory, category => category.parent)
children: PartCategory[];
}