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

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

export const IcrWordscategorySchema = defineEntity({
  class: IcrWordscategory,
  properties: {
    Id: p.bigint().primary().name('Id').unsigned(false).autoincrement(false).comment('主键Id'),
    StudentId: p.bigint().name('StudentId').comment('学生Id'),
    Name: p.string().name('Name').nullable().comment('名称'),
    ParentId: p.bigint().name('ParentId').nullable().comment('父分类ID（用于构建无限层级结构，根分类的ParentId为null）'),
    Path: p.string().name('Path').nullable().comment('分类层级路径，使用分隔符分隔的ID路径，如 "1/5/23"，便于快速查询和排序'),
    Level: p.integer().name('Level').comment('分类层级深度'),
    Type: p.integer().name('Type').comment('类型(0:默认 1:普通)'),
    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('是否删除'),
  },
});
