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

export class ScsClass {
  [PrimaryKeyProp]?: 'Id';
  Id!: IType<number, bigint>;
  SchoolId!: IType<number, bigint>;
  GradeId!: IType<number, bigint>;
  TeacherId!: IType<number, bigint>;
  Name?: string;
  Grid?: string;
  Camera?: string;
  Revision!: number;
  CreatedBy?: IType<number, bigint>;
  CreatedTime!: Date;
  UpdatedBy?: IType<number, bigint>;
  UpdatedTime?: Date;
  IsDeleted!: unknown;
  Description?: string;
  Code?: string;
  Type: number & Opt = 0;
}

export const ScsClassSchema = defineEntity({
  class: ScsClass,
  comment: '班级表',
  properties: {
    Id: p.bigint().primary().name('Id').columnType('bigint').unsigned(false).autoincrement(false).comment('主键Id'),
    SchoolId: p.bigint().name('SchoolId').columnType('bigint').comment('届id'),
    GradeId: p.bigint().name('GradeId').columnType('bigint').comment('届id'),
    TeacherId: p.bigint().name('TeacherId').columnType('bigint').comment('班主任id'),
    Name: p.string().name('Name').length(10).nullable().comment('班级名称'),
    Grid: p.string().name('Grid').length(10).nullable().comment('班级座次网格'),
    Camera: p.string().name('Camera').nullable().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('是否删除'),
    Description: p.string().name('Description').nullable().comment('描述'),
    Code: p.string().name('Code').nullable().comment('班级编码(两位01-99)').unique('idx_SCS_Class_01'),
    Type: p.integer().name('Type').comment('0-普通教室 1-辅导教室'),
  },
});
