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

export class OssResource {
  [PrimaryKeyProp]?: 'Id';
  Id!: bigint;
  MainId?: bigint;
  SoucePath?: string;
  Path?: string;
  Status!: number;
  Type!: number;
  Revision!: number;
  CreatedBy?: bigint;
  CreatedTime!: Date;
  UpdatedBy?: bigint;
  UpdatedTime?: Date;
  IsDeleted!: unknown;
}

export const OssResourceSchema = defineEntity({
  class: OssResource,
  comment: 'OSS资源表',
  properties: {
    Id: p.bigint().primary().name('Id').unsigned(false).autoincrement(false).comment('主键Id'),
    MainId: p.bigint().name('MainId').nullable().comment('主id'),
    SoucePath: p.string().name('SoucePath').length(3000).nullable().comment('原路径'),
    Path: p.string().name('Path').length(5000).nullable().comment('路径'),
    Status: p.integer().name('Status').comment('状态:0默认 1有效 -1失效'),
    Type: p.integer().name('Type').comment('共用桶情况类型(0-测试资源 1-正式资源)'),
    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('是否删除'),
  },
});
