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

export class IcrBookcatalog {
  [PrimaryKeyProp]?: 'Id';
  Id!: bigint;
  BookId!: bigint;
  Name?: string;
  Type!: number;
  ParentId!: bigint;
  Level!: number;
  Sort!: number;
  Revision!: number;
  CreatedBy?: bigint;
  CreatedTime!: Date;
  UpdatedBy?: bigint;
  UpdatedTime?: Date;
  IsDeleted!: unknown;
}

export const IcrBookcatalogSchema = defineEntity({
  class: IcrBookcatalog,
  properties: {
    Id: p.bigint().primary().name('Id').unsigned(false).autoincrement(false).comment('主键Id'),
    BookId: p.bigint().name('BookId').comment('书Id').index('idx_ICR_BookCatalog_01'),
    Name: p.string().name('Name').nullable().comment('目录名称'),
    Type: p.integer().name('Type').comment('类别:0-单元 1-页'),
    ParentId: p.bigint().name('ParentId').comment('父Id;无限级别'),
    Level: p.integer().name('Level').comment('等级'),
    Sort: p.integer().name('Sort').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('是否删除'),
  },
});
