Forráskód Böngészése

优化role 实体 定义

yourname 6 hónapja
szülő
commit
28d0340614
1 módosított fájl, 8 hozzáadás és 0 törlés
  1. 8 0
      src/server/modules/users/role.entity.ts

+ 8 - 0
src/server/modules/users/role.entity.ts

@@ -1,5 +1,7 @@
 import { Entity, PrimaryGeneratedColumn, Column } from 'typeorm';
 
+export type Permission = string;
+
 @Entity()
 export class Role {
   @PrimaryGeneratedColumn()
@@ -11,7 +13,13 @@ export class Role {
   @Column({ type: 'text', nullable: true })
   description?: string;
 
+  @Column({ type: 'simple-array', nullable: false })
+  permissions: Permission[] = [];
+
   constructor(partial?: Partial<Role>) {
     Object.assign(this, partial);
+    if (!this.permissions) {
+      this.permissions = [];
+    }
   }
 }