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

export class ScsSubject {
  [PrimaryKeyProp]?: 'Id';
  Id!: bigint;
  Code?: string;
  Name?: string;
  ShortName?: string;
  Revision!: number;
  CreatedBy?: bigint;
  CreatedTime!: Date;
  UpdatedBy?: bigint;
  UpdatedTime?: Date;
  IsDeleted!: unknown;
  Type: number & Opt = 1;
}

export const ScsSubjectSchema = defineEntity({
  class: ScsSubject,
  comment: '学科',
  properties: {
    Id: p.bigint().primary().name('Id').unsigned(false).autoincrement(false).comment('主键Id'),
    Code: p.string().name('Code').nullable().comment('学科编码'),
    Name: p.string().name('Name').nullable().comment('学科名称(来源字典)'),
    ShortName: p.string().name('ShortName').nullable().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('是否删除'),
    Type: p.integer().name('Type').comment('学科类型'),
  },
});
