/**
 * Instructor Entity
 * Instructores de capacitación HSE
 *
 * @module HSE
 * @table hse.instructores
 * @ddl schemas/03-hse-schema-ddl.sql
 * @rf RF-MAA017-002
 */

import {
  Entity,
  PrimaryGeneratedColumn,
  Column,
  CreateDateColumn,
  UpdateDateColumn,
  ManyToOne,
  JoinColumn,
} from 'typeorm';
import { Tenant } from '../../core/entities/tenant.entity';
import { Employee } from '../../hr/entities/employee.entity';

@Entity({ schema: 'hse', name: 'instructores' })
export class Instructor {
  @PrimaryGeneratedColumn('uuid')
  id: string;

  @Column({ name: 'tenant_id', type: 'uuid' })
  tenantId: string;

  @Column({ type: 'varchar', length: 200 })
  nombre: string;

  @Column({ name: 'registro_stps', type: 'varchar', length: 50, nullable: true })
  registroStps: string;

  @Column({ type: 'text', nullable: true })
  especialidades: string;

  @Column({ name: 'es_interno', type: 'boolean', default: false })
  esInterno: boolean;

  @Column({ name: 'employee_id', type: 'uuid', nullable: true })
  employeeId: string;

  @Column({ name: 'contacto_telefono', type: 'varchar', length: 20, nullable: true })
  contactoTelefono: string;

  @Column({ name: 'contacto_email', type: 'varchar', length: 100, nullable: true })
  contactoEmail: string;

  @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;

  @ManyToOne(() => Employee)
  @JoinColumn({ name: 'employee_id' })
  employee: Employee;
}
