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

/**
 * 审核配置规则表 - 配置不同条件下使用哪个Agent进行审核
 * 匹配逻辑：条件为空表示匹配所有，多条规则命中时优先级高的生效
 */
@Entity('audit_config')
export class AuditConfigEntity extends BaseEntity {
  @Column({ comment: '规则名称', length: 100 })
  name: string;

  @Column({
    comment: '订单类型 insure=投保 claim=理赔, 为空表示匹配所有',
    length: 20,
    nullable: true,
  })
  orderType: string;

  @Column({ comment: '主机厂ID, 为空表示匹配所有', nullable: true })
  oemId: number;

  @Column({ comment: '主机厂名称(展示用)', length: 100, nullable: true })
  oemName: string;

  @Column({
    comment: '产品名称关键词, 为空表示匹配所有, 支持模糊匹配',
    length: 200,
    nullable: true,
  })
  productKeyword: string;

  @Column({ comment: '产品编号, 为空表示匹配所有', length: 100, nullable: true })
  productNo: string;

  @Column({ comment: '产品名称(展示用)', length: 200, nullable: true })
  productName: string;

  @Column({
    comment: '车辆类型 0=新车 1=在用车, 为空表示匹配所有',
    length: 10,
    nullable: true,
  })
  carType: string;

  @Column({
    comment: '动力类型 1=燃油 2=新能源, 长安专用, 为空表示匹配所有',
    length: 20,
    nullable: true,
  })
  carPower: string;

  @Index()
  @Column({ comment: '关联的Agent ID' })
  agentId: number;

  @Column({ comment: '关联的Agent ID列表', type: 'json', nullable: true })
  agentIds: number[];

  @Column({ comment: 'Agent名称(展示用)', length: 200, nullable: true })
  agentName: string;

  @Index()
  @Column({ comment: '优先级, 数字越大越优先', default: 0 })
  priority: number;

  @Index()
  @Column({ comment: '状态 0=禁用 1=启用', default: 1 })
  status: number;

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