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

export class IcrClassroomcourse {
  [PrimaryKeyProp]?: 'Id';
  Id!: IType<number, bigint>;
  SchoolId?: IType<number, bigint>;
  GradeId?: IType<number, bigint>;
  ClassId!: IType<number, bigint>;
  TeacherId!: IType<number, bigint>;
  SubjectId!: IType<number, bigint>;
  Title?: string;
  ActiveDate!: Date;
  ActiveWeekNum!: number;
  ActiveTimeStart?: Date;
  ActiveTimeEnd?: Date;
  Status!: number;
  HandsUpStatus!: number;
  BulletScreenStatus!: number;
  StartPointTimes?: unknown;
  Remark?: string;
  Revision!: number;
  CreatedBy?: IType<number, bigint>;
  CreatedTime!: Date;
  UpdatedBy?: IType<number, bigint>;
  UpdatedTime?: Date;
  IsDeleted!: unknown;
  HomeworkId!: IType<number, bigint> & Opt;
}

export const IcrClassroomcourseSchema = defineEntity({
  class: IcrClassroomcourse,
  comment: '课堂课程(本班)',
  properties: {
    Id: p.bigint().primary().name('Id').columnType('bigint').unsigned(false).autoincrement(false).comment('主键Id'),
    SchoolId: p.bigint().name('SchoolId').columnType('bigint').nullable().comment('授课学校id'),
    GradeId: p.bigint().name('GradeId').columnType('bigint').nullable().comment('授课年级id'),
    ClassId: p.bigint().name('ClassId').columnType('bigint').comment('授课本班编号'),
    TeacherId: p.bigint().name('TeacherId').columnType('bigint').comment('教师编号'),
    SubjectId: p.bigint().name('SubjectId').columnType('bigint').comment('学科编号'),
    Title: p.string().name('Title').nullable().comment('课程标题（可选）'),
    ActiveDate: p.datetime().name('ActiveDate').length(3).comment('授课时间（天）'),
    ActiveWeekNum: p.integer().name('ActiveWeekNum').comment('周几'),
    ActiveTimeStart: p.datetime().name('ActiveTimeStart').length(3).nullable().comment('授课开始时间'),
    ActiveTimeEnd: p.datetime().name('ActiveTimeEnd').length(3).nullable().comment('授课结束时间;若为主动结束课程，系统自动处理'),
    Status: p.integer().name('Status').comment('授课状态;0 未开始 1 已开始 200 授课正常结束 201 系统关闭课程'),
    HandsUpStatus: p.integer().name('HandsUpStatus').comment('举手状态'),
    BulletScreenStatus: p.integer().name('BulletScreenStatus').comment('弹幕状态'),
    StartPointTimes: p.array().name('StartPointTimes').length(16777215).nullable().comment('开始点'),
    Remark: p.string().name('Remark').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('是否删除'),
    HomeworkId: p.bigint().name('HomeworkId').columnType('bigint').comment('作业Id').defaultRaw(`0`),
  },
});
