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

export class ScsPermissions {
  id!: bigint;
  parentid!: bigint;
  name?: string;
  label?: string;
  code?: string;
  Path?: string;
  identification?: string;
  icon?: string;
  sort!: number;
  description?: string;
  enabled!: unknown;
  revision!: number;
  createdby?: bigint;
  createdtime!: Date;
  updatedby?: bigint;
  updatedtime?: Date;
  isdeleted!: unknown;
  Type!: number;
  Hide!: unknown & Opt;
}

export const ScsPermissionsSchema = defineEntity({
  class: ScsPermissions,
  comment: '权限表',
  properties: {
    id: p.bigint().primary().unsigned(false).autoincrement(false).comment('主键Id'),
    parentid: p.bigint().comment('父id').index('idx_SCS_Permissions_03'),
    name: p.string().length(20).nullable().comment('菜单名称'),
    label: p.string().length(50).nullable().comment('路由名称').index('idx_SCS_Permissions_01'),
    code: p.string().length(50).nullable().comment('路由路径').index('idx_SCS_Permissions_02'),
    Path: p.string().name('Path').length(100).nullable().comment('组件路径'),
    identification: p.string().length(20).nullable().comment('权限标识'),
    icon: p.string().nullable().comment('图标'),
    sort: p.integer().comment('排序'),
    description: p.string().nullable().comment('描述'),
    enabled: p.array().comment('启用'),
    revision: p.integer().comment('乐观锁'),
    createdby: p.bigint().nullable().comment('创建者用户Id'),
    createdtime: p.datetime().length(3).comment('创建时间'),
    updatedby: p.bigint().nullable().comment('修改者用户Id'),
    updatedtime: p.datetime().length(3).nullable().comment('修改时间'),
    isdeleted: p.array().comment('是否删除'),
    Type: p.integer().name('Type').comment('类型'),
    Hide: p.array().name('Hide').comment('隐藏').defaultRaw(`b'0'`),
  },
});
