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

export class ScsClass {
  [PrimaryKeyProp]?: 'Id';
  Id!: bigint;
  SchoolId!: bigint;
  GradeId!: bigint;
  TeacherId!: bigint;
  Name?: string;
  Grid?: string;
  Camera?: string;
  Revision!: number;
  CreatedBy?: bigint;
  CreatedTime!: Date;
  UpdatedBy?: 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').unsigned(false).autoincrement(false).comment('主键Id'),
    SchoolId: p.bigint().name('SchoolId').comment('届id'),
    GradeId: p.bigint().name('GradeId').comment('届id'),
    TeacherId: p.bigint().name('TeacherId').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').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('是否删除'),
    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-辅导教室'),
  },
});
