import {
  Column, CreateDateColumn, DeleteDateColumn, Entity,
  PrimaryGeneratedColumn, UpdateDateColumn,
} from 'typeorm';

@Entity('documents')
export class Document {
  @PrimaryGeneratedColumn('uuid') id: string;

  @Column({ type: 'varchar', length: 300 }) name: string;
  @Column({ type: 'varchar', length: 300, nullable: true }) nameNe: string | null;

  @Column({ type: 'varchar', length: 40, default: 'general' })
  category: 'member' | 'loan' | 'savings' | 'minutes' | 'policy' | 'legal' | 'general';

  @Column({ type: 'varchar', length: 300, nullable: true }) filePath: string | null;
  @Column({ type: 'integer', nullable: true }) fileSize: number | null;
  @Column({ type: 'varchar', length: 100, nullable: true }) mimeType: string | null;
  @Column({ type: 'varchar', length: 20, nullable: true }) fileExtension: string | null;

  @Column({ type: 'text', nullable: true }) description: string | null;
  @Column({ type: 'text', nullable: true }) tags: string | null;
  @Column({ type: 'text', nullable: true }) ocrText: string | null;

  @Column({ type: 'varchar', nullable: true }) memberId: string | null;
  @Column({ type: 'varchar', length: 300, nullable: true }) memberName: string | null;

  @Column({ type: 'varchar', nullable: true }) relatedEntityId: string | null;
  @Column({ type: 'varchar', length: 50, nullable: true }) relatedEntityType: string | null;

  @Column({ type: 'varchar', nullable: true }) officeId: string | null;
  @Column({ type: 'varchar', nullable: true }) uploadedById: string | null;
  @Column({ type: 'varchar', length: 200, nullable: true }) uploadedByName: string | null;

  @Column({ default: false }) isPublic: boolean;

  @CreateDateColumn() createdAt: Date;
  @UpdateDateColumn() updatedAt: Date;
  @DeleteDateColumn() deletedAt: Date | null;
}
