import { Entity, Column, PrimaryGeneratedColumn, ManyToOne, JoinColumn, CreateDateColumn } from 'typeorm';
import { DisabledPerson } from './disabled-person.entity';

@Entity('disabled_remark')
export class DisabledRemark {
  @PrimaryGeneratedColumn({
    name: 'remark_id',
    type: 'int',
    comment: '备注ID'
  })
  id!: number;

  @Column({
    name: 'person_id',
    type: 'int',
    nullable: false,
    comment: '残疾人ID'
  })
  personId!: number;

  @Column({
    name: 'remark_content',
    type: 'text',
    nullable: false,
    comment: '备注内容'
  })
  remarkContent!: string;

  @Column({
    name: 'is_special_needs',
    type: 'smallint',
    nullable: false,
    default: 0,
    comment: '是否特殊需求：1-是，0-否'
  })
  isSpecialNeeds!: number;

  @CreateDateColumn({
    name: 'remark_time',
    type: 'timestamp',
    nullable: false,
    default: () => 'CURRENT_TIMESTAMP',
    comment: '备注时间'
  })
  remarkTime!: Date;

  @Column({
    name: 'operator_id',
    type: 'int',
    nullable: false,
    comment: '操作人ID'
  })
  operatorId!: number;

  // 关系定义
  @ManyToOne(() => DisabledPerson, person => person.remarks, { onDelete: 'CASCADE' })
  @JoinColumn({ name: 'person_id' })
  person!: DisabledPerson;
}