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

export class ScsSource {
  [PrimaryKeyProp]?: 'Id';
  Id!: bigint;
  No!: bigint;
  PublisherId!: bigint;
  GradeId!: bigint;
  SubjectId!: bigint;
  Name?: string;
  Status!: number;
  Revision!: number;
  CreatedBy?: bigint;
  CreatedTime!: Date;
  UpdatedBy?: bigint;
  UpdatedTime?: Date;
  IsDeleted!: unknown;
  SchoolId!: bigint;
  ViewNum: number & Opt = 0;
  DownNum: number & Opt = 0;
}

export const ScsSourceSchema = defineEntity({
  class: ScsSource,
  comment: '资源包',
  properties: {
    Id: p.bigint().primary().name('Id').unsigned(false).autoincrement(false).comment('主键Id'),
    No: p.bigint().name('No').comment('作品id'),
    PublisherId: p.bigint().name('PublisherId').comment('上传用户id'),
    GradeId: p.bigint().name('GradeId').comment('届id'),
    SubjectId: p.bigint().name('SubjectId').comment('学科id'),
    Name: p.string().name('Name').nullable().comment('文件包名称').index('idx_SCS_Source_01'),
    Status: p.integer().name('Status').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('是否删除'),
    SchoolId: p.bigint().name('SchoolId').comment('学校id(如果学校id)'),
    ViewNum: p.integer().name('ViewNum').comment('浏览量'),
    DownNum: p.integer().name('DownNum').comment('下载量'),
  },
});
