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

export class IcrQuestionbank {
  [PrimaryKeyProp]?: 'Id';
  Id!: IType<number, bigint>;
  SubjectId!: IType<number, bigint>;
  Type!: number;
  Source!: number;
  Difficulty!: number;
  GradeLevel!: number;
  GradeNum!: number;
  Image?: string;
  Question?: string;
  Answer?: string;
  Analysis?: string;
  VideoUrl?: string;
  KnowledgepointIds?: unknown;
  Revision!: number;
  CreatedBy?: IType<number, bigint>;
  CreatedTime!: Date;
  UpdatedBy?: IType<number, bigint>;
  UpdatedTime?: Date;
  IsDeleted!: unknown;
  QuestionUrl?: string;
  Options?: unknown;
  AnalysisUrl?: string;
}

export const IcrQuestionbankSchema = defineEntity({
  class: IcrQuestionbank,
  comment: '题库',
  properties: {
    Id: p.bigint().primary().name('Id').columnType('bigint').unsigned(false).autoincrement(false).comment('主键Id'),
    SubjectId: p.bigint().name('SubjectId').columnType('bigint').comment('学科'),
    Type: p.integer().name('Type').comment('题型'),
    Source: p.integer().name('Source').comment('来源'),
    Difficulty: p.integer().name('Difficulty').comment('难度'),
    GradeLevel: p.integer().name('GradeLevel').comment('学级(0-小 1-初 2-高)'),
    GradeNum: p.integer().name('GradeNum').comment('年级'),
    Image: p.string().name('Image').nullable().comment('原图'),
    Question: p.text().name('Question').length(65535).nullable().comment('问题'),
    Answer: p.string().name('Answer').nullable().comment('答案'),
    Analysis: p.text().name('Analysis').length(65535).nullable().comment('解析'),
    VideoUrl: p.string().name('VideoUrl').nullable().comment('视频讲解地址'),
    KnowledgepointIds: p.array().name('KnowledgepointIds').length(4294967295).nullable().comment('关联的知识点ids'),
    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('是否删除'),
    QuestionUrl: p.string().name('QuestionUrl').nullable().comment('问题图'),
    Options: p.array().name('Options').length(4294967295).nullable().comment('选项'),
    AnalysisUrl: p.string().name('AnalysisUrl').nullable().comment('解析图片'),
  },
});
