69 lines
1.4 KiB
TypeScript
69 lines
1.4 KiB
TypeScript
/**
|
|
* Puesto Entity
|
|
* Catálogo de puestos de trabajo
|
|
*
|
|
* @module HR
|
|
* @table hr.puestos
|
|
* @ddl schemas/02-hr-schema-ddl.sql
|
|
*/
|
|
|
|
import {
|
|
Entity,
|
|
PrimaryGeneratedColumn,
|
|
Column,
|
|
CreateDateColumn,
|
|
UpdateDateColumn,
|
|
ManyToOne,
|
|
OneToMany,
|
|
JoinColumn,
|
|
Index,
|
|
} from 'typeorm';
|
|
import { Tenant } from '../../core/entities/tenant.entity';
|
|
import { Employee } from './employee.entity';
|
|
|
|
@Entity({ schema: 'hr', name: 'puestos' })
|
|
@Index(['tenantId', 'codigo'], { unique: true })
|
|
export class Puesto {
|
|
@PrimaryGeneratedColumn('uuid')
|
|
id: string;
|
|
|
|
@Column({ name: 'tenant_id', type: 'uuid' })
|
|
tenantId: string;
|
|
|
|
@Column({ type: 'varchar', length: 20 })
|
|
codigo: string;
|
|
|
|
@Column({ type: 'varchar', length: 100 })
|
|
nombre: string;
|
|
|
|
@Column({ type: 'text', nullable: true })
|
|
descripcion: string;
|
|
|
|
@Column({ name: 'nivel_riesgo', type: 'varchar', length: 20, nullable: true })
|
|
nivelRiesgo: string;
|
|
|
|
@Column({
|
|
name: 'requiere_capacitacion_especial',
|
|
type: 'boolean',
|
|
default: false
|
|
})
|
|
requiereCapacitacionEspecial: boolean;
|
|
|
|
@Column({ type: 'boolean', default: true })
|
|
activo: boolean;
|
|
|
|
@CreateDateColumn({ name: 'created_at', type: 'timestamptz' })
|
|
createdAt: Date;
|
|
|
|
@UpdateDateColumn({ name: 'updated_at', type: 'timestamptz' })
|
|
updatedAt: Date;
|
|
|
|
// Relations
|
|
@ManyToOne(() => Tenant)
|
|
@JoinColumn({ name: 'tenant_id' })
|
|
tenant: Tenant;
|
|
|
|
@OneToMany(() => Employee, (e) => e.puesto)
|
|
empleados: Employee[];
|
|
}
|