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

export class ScsCourse {
  [PrimaryKeyProp]?: 'Id';
  Id!: IType<number, bigint>;
  SchoolId!: IType<number, bigint>;
  SubjectId!: IType<number, bigint>;
  GradeId!: IType<number, bigint>;
  GradeLevel!: number;
  CourseStatus!: number;
  GradeLevelNum!: number;
  Cover?: string;
  Name?: string;
  TeacherId!: IType<number, bigint>;
  WeekNum!: number;
  WeekDay!: number;
  CoursewareCount!: number;
  KnowledgeCount!: number;
  OtherCount!: number;
  ViewCount!: number;
  DurationSeconds!: number;
  Revision!: number;
  CreatedBy?: IType<number, bigint>;
  CreatedTime!: Date;
  UpdatedBy?: IType<number, bigint>;
  UpdatedTime?: Date;
  IsDeleted!: unknown;
}

export const ScsCourseSchema = defineEntity({
  class: ScsCourse,
  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'),
    SubjectId: p.bigint().name('SubjectId').columnType('bigint').comment('学科id'),
    GradeId: p.bigint().name('GradeId').columnType('bigint').comment('届id'),
    GradeLevel: p.integer().name('GradeLevel').comment('届比如高(冗余字段)'),
    CourseStatus: p.integer().name('CourseStatus').comment('课程状态'),
    GradeLevelNum: p.integer().name('GradeLevelNum').comment('届级别编号(高1的1)(冗余字段)'),
    Cover: p.string().name('Cover').length(1000).nullable().comment('封面'),
    Name: p.string().name('Name').nullable().comment('课程名称'),
    TeacherId: p.bigint().name('TeacherId').columnType('bigint').comment('讲师id'),
    WeekNum: p.integer().name('WeekNum').comment('学习周'),
    WeekDay: p.integer().name('WeekDay').comment('星期(星期一)'),
    CoursewareCount: p.integer().name('CoursewareCount').comment('课件数量'),
    KnowledgeCount: p.integer().name('KnowledgeCount').comment('知识点数量'),
    OtherCount: p.integer().name('OtherCount').comment('其他数量'),
    ViewCount: p.integer().name('ViewCount').comment('查看量'),
    DurationSeconds: p.integer().name('DurationSeconds').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('是否删除'),
  },
});
