import { BaseEntity } from '../../base/entity/base';
import { Column, Entity, Index } from 'typeorm';

/**
 * 项目任务
 */
@Entity('project_task')
export class ProjectTaskEntity extends BaseEntity {
  @Index()
  @Column({ comment: '所属项目ID' })
  projectId: number;

  @Index()
  @Column({ comment: '所属阶段ID', nullable: true })
  phaseId: number;

  @Index()
  @Column({ comment: '父任务ID', nullable: true })
  parentId: number;

  @Column({ comment: '任务名称', length: 200 })
  name: string;

  @Column({ comment: '任务描述', type: 'text', nullable: true })
  description: string;

  @Column({ comment: '状态 0待办 1进行中 2已完成 3已关闭', default: 0 })
  status: number;

  @Column({ comment: '优先级 0紧急 1高 2中 3低', default: 2 })
  priority: number;

  @Column({ comment: '分类', length: 50, nullable: true })
  category: string;

  @Index()
  @Column({ comment: '负责人ID', nullable: true })
  assigneeId: number;

  @Column({ comment: '负责人姓名', length: 50, nullable: true })
  assigneeName: string;

  @Column({ comment: '计划开始日期', type: 'date', nullable: true })
  startDate: string;

  @Column({ comment: '计划结束日期', type: 'date', nullable: true })
  endDate: string;

  @Column({ comment: '预估工时(小时)', type: 'decimal', precision: 8, scale: 1, default: 0 })
  estimatedHours: number;

  @Column({ comment: '实际工时(小时)', type: 'decimal', precision: 8, scale: 1, default: 0 })
  actualHours: number;

  @Column({ comment: '进度 0-100', default: 0 })
  progress: number;

  @Column({ comment: '排序序号', default: 0 })
  sortOrder: number;

  @Column({ comment: '自定义颜色', length: 20, nullable: true })
  color: string;
}
