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

export class IcrBooks {
  [PrimaryKeyProp]?: 'Id';
  Id!: IType<number, bigint>;
  Name?: string;
  BookCategoryId!: IType<number, bigint>;
  GradeLevel!: number;
  GradeNum!: number;
  SubjectId!: IType<number, bigint>;
  TotalPage!: number;
  VerifyPage!: number;
  Status!: number;
  PdfUrl?: string;
  Width!: number;
  Height!: number;
  BookType!: number;
  Type!: number;
  Revision!: number;
  CreatedBy?: IType<number, bigint>;
  CreatedTime!: Date;
  UpdatedBy?: IType<number, bigint>;
  UpdatedTime?: Date;
  IsDeleted!: unknown;
  Result!: number;
  Cover?: string;
  BackCover?: string;
  PdfPreviewUrl?: string;
  Conclusion?: any;
}

export const IcrBooksSchema = defineEntity({
  class: IcrBooks,
  comment: '书籍',
  properties: {
    Id: p.bigint().primary().name('Id').columnType('bigint').unsigned(false).autoincrement(false).comment('主键Id'),
    Name: p.string().name('Name').nullable().comment('书籍名称'),
    BookCategoryId: p.bigint().name('BookCategoryId').columnType('bigint').comment('类别Id').index('idx_ICR_Books_01'),
    GradeLevel: p.integer().name('GradeLevel').comment('适用年级(小 初 高)'),
    GradeNum: p.integer().name('GradeNum').comment('适用年级'),
    SubjectId: p.bigint().name('SubjectId').columnType('bigint').comment('适用学科(和类别相关)'),
    TotalPage: p.integer().name('TotalPage').comment('总页数'),
    VerifyPage: p.integer().name('VerifyPage').comment('校验页数'),
    Status: p.integer().name('Status').comment('状态'),
    PdfUrl: p.string().name('PdfUrl').nullable().comment('pdf地址'),
    Width: p.float().name('Width').comment('宽度'),
    Height: p.float().name('Height').comment('高度'),
    BookType: p.integer().name('BookType').comment('1书籍/2卷子'),
    Type: p.integer().name('Type').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('是否删除'),
    Result: p.integer().name('Result').comment('审查结果(默认0 1通过 -1驳回)'),
    Cover: p.string().name('Cover').nullable().comment('封面'),
    BackCover: p.string().name('BackCover').nullable().comment('封底'),
    PdfPreviewUrl: p.string().name('PdfPreviewUrl').nullable().comment('pdf预览地址'),
    Conclusion: p.json().name('Conclusion').nullable().comment('结论Json'),
  },
});
