role.entity.mt.ts 907 B

123456789101112131415161718192021222324252627282930313233343536
  1. import { Entity, PrimaryGeneratedColumn, Column, CreateDateColumn, UpdateDateColumn } from 'typeorm';
  2. // 定义 Permission 类型
  3. export type Permission = string;
  4. @Entity({ name: 'roles_mt' })
  5. export class RoleMt {
  6. @PrimaryGeneratedColumn()
  7. id!: number;
  8. @Column({ name: 'tenant_id', type: 'int', unsigned: true, comment: '租户ID' })
  9. tenantId!: number;
  10. @Column({ type: 'varchar', length: 50 })
  11. name!: string;
  12. @Column({ type: 'text', nullable: true })
  13. description!: string | null;
  14. @Column({ type: 'simple-array', nullable: false })
  15. permissions: Permission[] = [];
  16. @CreateDateColumn({ name: 'created_at', type: 'timestamp' })
  17. createdAt!: Date;
  18. @UpdateDateColumn({ name: 'updated_at', type: 'timestamp' })
  19. updatedAt!: Date;
  20. constructor(partial?: Partial<RoleMt>) {
  21. Object.assign(this, partial);
  22. if (!this.permissions) {
  23. this.permissions = [];
  24. }
  25. }
  26. }