import { Entity, PrimaryGeneratedColumn, Column, CreateDateColumn, UpdateDateColumn, OneToMany } from 'typeorm';
import { ItemLinha } from './item-linha.entity';

@Entity('demandas')
export class Demanda {
  @PrimaryGeneratedColumn('uuid')
  id: string;

  @Column({ type: 'integer', unique: true, nullable: true })
  numero: number;

  @Column({ length: 300 })
  titulo: string;

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

  @Column()
  local_id: string;

  @Column()
  centro_custo_id: string;

  @Column()
  categoria_id: string;

  @Column({ nullable: true })
  subcategoria_id: string;

  @Column({ length: 20 })
  criticidade: string;

  @Column({ nullable: true })
  data_desejada: string;

  @Column({ length: 30, default: 'rascunho' })
  status: string;

  @Column()
  solicitante_id: string;

  @Column({ nullable: true })
  gestor_id: string;

  @Column({ type: 'float', nullable: true })
  valor_estimado: number;

  @Column({ length: 20, nullable: true })
  impacto_ambiental_demanda: string;

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

  @Column({ type: 'simple-json', default: '[]' })
  documentos: any;

  @OneToMany(() => ItemLinha, i => i.demanda)
  itens_linha: ItemLinha[];

  @CreateDateColumn()
  created_at: Date;

  @UpdateDateColumn()
  updated_at: Date;
}
