import { type IType, type Opt, PrimaryKeyProp, defineEntity, p } from '@mikro-orm/core';

export class IcrHomeworkanswersnapshoot {
  [PrimaryKeyProp]?: 'Id';
  Id!: IType<number, bigint>;
  HomeworkId!: IType<number, bigint>;
  BookPageId!: IType<number, bigint>;
  BookPageNum!: number;
  BooksPageQuestionId!: IType<number, bigint>;
  BooksPageQuestionGroupId!: IType<number, bigint>;
  StudentId!: IType<number, bigint>;
  Result?: string;
  Score!: number;
  QuestioAnswerUrl?: string;
  AnswerUrl?: string;
  PageAnswerUrl?: string;
  ReviewId!: IType<number, bigint>;
  ReviewUrl?: string;
  AudioStartTime!: IType<number, bigint>;
  AudioEndTime!: IType<number, bigint>;
  AudioUrl?: string;
  PointsUrl?: string;
  AnswerStatus!: number;
  Status!: number;
  Date!: IType<number, bigint>;
  AsnwerStartTime?: Date;
  AsnwerEndTime?: Date;
  AnswerSeconds!: number;
  ImageRecognition!: number;
  Revision!: number;
  CreatedBy?: IType<number, bigint>;
  CreatedTime!: Date;
  UpdatedBy?: IType<number, bigint>;
  UpdatedTime?: Date;
  IsDeleted!: unknown;
  HomeworkAnswerId!: IType<number, bigint> & Opt;
}

export const IcrHomeworkanswersnapshootSchema = defineEntity({
  class: IcrHomeworkanswersnapshoot,
  comment: '作业回答',
  properties: {
    Id: p.bigint().primary().name('Id').columnType('bigint').unsigned(false).autoincrement(false).comment('主键Id'),
    HomeworkId: p.bigint().name('HomeworkId').columnType('bigint').comment('作业id'),
    BookPageId: p.bigint().name('BookPageId').columnType('bigint').comment('作业页id'),
    BookPageNum: p.integer().name('BookPageNum').comment('作业页页码'),
    BooksPageQuestionId: p.bigint().name('BooksPageQuestionId').columnType('bigint').comment('作业问题id').index('idx_ICR_HomeworkAnswerSnapshoot_01'),
    BooksPageQuestionGroupId: p.bigint().name('BooksPageQuestionGroupId').columnType('bigint').comment('作业问题grouipId'),
    StudentId: p.bigint().name('StudentId').columnType('bigint').comment('答题人id'),
    Result: p.string().name('Result').nullable().comment('答题结果'),
    Score: p.integer().name('Score').comment('答题得分'),
    QuestioAnswerUrl: p.string().name('QuestioAnswerUrl').nullable().comment('答题结果图片地址(包含答题内容)'),
    AnswerUrl: p.string().name('AnswerUrl').nullable().comment('答题结果图片地址(只包含答题内容框)'),
    PageAnswerUrl: p.string().name('PageAnswerUrl').nullable().comment('答题结果图片地址'),
    ReviewId: p.bigint().name('ReviewId').columnType('bigint').comment('批阅人id'),
    ReviewUrl: p.string().name('ReviewUrl').nullable().comment('批阅人url'),
    AudioStartTime: p.bigint().name('AudioStartTime').columnType('bigint').comment('音频开始时间'),
    AudioEndTime: p.bigint().name('AudioEndTime').columnType('bigint').comment('音频结束时间'),
    AudioUrl: p.string().name('AudioUrl').nullable().comment('音频地址'),
    PointsUrl: p.string().name('PointsUrl').nullable().comment('点位数据地址'),
    AnswerStatus: p.integer().name('AnswerStatus').comment('答题状态'),
    Status: p.integer().name('Status').comment('批阅状态 0-未批阅 1-已批阅'),
    Date: p.bigint().name('Date').columnType('bigint').comment('日期 yyyyMMdd'),
    AsnwerStartTime: p.datetime().name('AsnwerStartTime').length(3).nullable().comment('开始答题时间'),
    AsnwerEndTime: p.datetime().name('AsnwerEndTime').length(3).nullable().comment('开始结束时间'),
    AnswerSeconds: p.integer().name('AnswerSeconds').comment('答题时间(秒)'),
    ImageRecognition: p.integer().name('ImageRecognition').comment('识别状态'),
    Revision: p.integer().name('Revision').comment('乐观锁'),
    CreatedBy: p.bigint().name('CreatedBy').columnType('bigint').nullable().comment('创建者用户Id'),
    CreatedTime: p.datetime().name('CreatedTime').length(3).comment('创建时间'),
    UpdatedBy: p.bigint().name('UpdatedBy').columnType('bigint').nullable().comment('修改者用户Id'),
    UpdatedTime: p.datetime().name('UpdatedTime').length(3).nullable().comment('修改时间'),
    IsDeleted: p.array().name('IsDeleted').comment('是否删除'),
    HomeworkAnswerId: p.bigint().name('HomeworkAnswerId').columnType('bigint').comment('回答id').defaultRaw(`0`),
  },
});
