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

/**
 * 审核明细表 - 记录每个审核步骤的Skill执行结果
 * 如身份证OCR结果、购车发票OCR结果、数据比对结果、规则校验结果等
 */
@Entity('audit_order_detail')
export class AuditOrderDetailEntity extends BaseEntity {
  @Index()
  @Column({ comment: '关联审核订单ID（audit_order.id）' })
  orderId: number;

  @Column({
    comment: '步骤类型 id_card_ocr/invoice_ocr/driving_license_ocr/data_compare/rule_check/damage_detect/llm_judge',
    length: 30,
  })
  stepType: string;

  @Column({ comment: '步骤名称（中文展示用）', length: 100 })
  stepName: string;

  @Column({ comment: '调用的Skill标识', length: 50, nullable: true })
  skillName: string;

  @Column({
    comment: 'Skill输入数据',
    type: 'json',
    transformer: transformerJson,
    nullable: true,
  })
  inputData: any;

  @Column({
    comment: 'Skill输出结果（OCR字段、比对结果等）',
    type: 'json',
    transformer: transformerJson,
    nullable: true,
  })
  outputData: any;

  @Column({
    comment: '该步骤评分（0-100）',
    type: 'decimal',
    precision: 5,
    scale: 2,
    nullable: true,
  })
  score: number;

  @Column({ comment: '该步骤是否通过 0=否 1=是 2=警告', type: 'tinyint', nullable: true })
  passed: number;

  @Column({ comment: '备注/原因', type: 'text', nullable: true })
  remark: string;

  @Column({ comment: '该步骤耗时(ms)', nullable: true })
  duration: number;
}
