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

export class IcrHomeworkanswer {
  [PrimaryKeyProp]?: 'Id';
  Id!: bigint;
  HomeworkId!: bigint;
  BooksPageQuestionId!: bigint;
  BooksPageQuestionGroupId!: bigint;
  StudentId!: bigint;
  Result?: string;
  Score!: number;
  QuestioAnswerUrl?: string;
  AnswerUrl?: string;
  PageAnswerUrl?: string;
  ReviewId?: bigint;
  ReviewUrl?: string;
  PointsUrl?: string;
  AnswerStatus!: number;
  Status!: number;
  AsnwerStartTime?: Date;
  AsnwerEndTime?: Date;
  AnswerSeconds!: number;
  Revision!: number;
  CreatedBy?: bigint;
  CreatedTime!: Date;
  UpdatedBy?: bigint;
  UpdatedTime?: Date;
  IsDeleted!: unknown;
  BookPageId!: bigint & Opt;
  BookPageNum: number & Opt = 0;
  ReviewPageUrl?: string;
  ImageRecognition: number & Opt = 0;
  Modify: number & Opt = 0;
  LastTag!: bigint & Opt;
  DotPageNo?: string;
  PageAnswerDotUrl?: string;
}

export const IcrHomeworkanswerSchema = defineEntity({
  class: IcrHomeworkanswer,
  comment: '作业回答',
  properties: {
    Id: p.bigint().primary().name('Id').unsigned(false).autoincrement(false).comment('主键Id'),
    HomeworkId: p.bigint().name('HomeworkId').comment('作业id').index('idx_ICR_HomeworkAnswer_01'),
    BooksPageQuestionId: p.bigint().name('BooksPageQuestionId').comment('作业问题id').index('idx_ICR_HomeworkAnswer_03'),
    BooksPageQuestionGroupId: p.bigint().name('BooksPageQuestionGroupId').comment('作业问题grouipId').index('idx_ICR_HomeworkAnswer_04'),
    StudentId: p.bigint().name('StudentId').comment('答题人id').index('idx_ICR_HomeworkAnswer_05'),
    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').nullable().comment('批阅人id'),
    ReviewUrl: p.string().name('ReviewUrl').nullable().comment('批阅人图片地址(问题)'),
    PointsUrl: p.string().name('PointsUrl').nullable().comment('点位数据地址'),
    AnswerStatus: p.integer().name('AnswerStatus').comment('答题状态'),
    Status: p.integer().name('Status').comment('批阅状态 0-未批阅 1-已批阅'),
    AsnwerStartTime: p.datetime().name('AsnwerStartTime').length(3).nullable().comment('开始答题时间'),
    AsnwerEndTime: p.datetime().name('AsnwerEndTime').length(3).nullable().comment('开始结束时间'),
    AnswerSeconds: p.integer().name('AnswerSeconds').comment('答题时间(秒)'),
    Revision: p.integer().name('Revision').comment('乐观锁'),
    CreatedBy: p.bigint().name('CreatedBy').nullable().comment('创建者用户Id'),
    CreatedTime: p.datetime().name('CreatedTime').length(3).comment('创建时间'),
    UpdatedBy: p.bigint().name('UpdatedBy').nullable().comment('修改者用户Id'),
    UpdatedTime: p.datetime().name('UpdatedTime').length(3).nullable().comment('修改时间'),
    IsDeleted: p.array().name('IsDeleted').comment('是否删除'),
    BookPageId: p.bigint().name('BookPageId').comment('作业页id').defaultRaw(`0`).index('idx_ICR_HomeworkAnswer_02'),
    BookPageNum: p.integer().name('BookPageNum').comment('作业页页码'),
    ReviewPageUrl: p.string().name('ReviewPageUrl').nullable().comment('批阅人图片地址(整页)'),
    ImageRecognition: p.integer().name('ImageRecognition').comment('识别状态'),
    Modify: p.integer().name('Modify').comment('修改次数累加'),
    LastTag: p.bigint().name('LastTag').comment('最后修改标记').defaultRaw(`0`),
    DotPageNo: p.string().name('DotPageNo').nullable().comment('点阵页码'),
    PageAnswerDotUrl: p.string().name('PageAnswerDotUrl').nullable().comment('答题结果点阵图片地址'),
  },
});
