50 lines
878 B
TypeScript
50 lines
878 B
TypeScript
import { PrimaryGeneratedColumn, Column, OneToMany, Entity, ManyToOne } from "typeorm";
|
|
import {
|
|
IsInt,
|
|
IsNotEmpty,
|
|
IsOptional,
|
|
IsString,
|
|
} from "class-validator";
|
|
import { User } from './User';
|
|
import { UserGroup } from './UserGroup';
|
|
/**
|
|
* Defines the Permission interface.
|
|
*/
|
|
@Entity()
|
|
export abstract class Permission {
|
|
/**
|
|
* Autogenerated unique id (primary key).
|
|
*/
|
|
@PrimaryGeneratedColumn()
|
|
@IsOptional()
|
|
@IsInt()
|
|
id: number;
|
|
|
|
/**
|
|
* users
|
|
*/
|
|
@OneToMany(() => User, user => user.permissions, { nullable: true })
|
|
users: User[]
|
|
|
|
/**
|
|
* groups
|
|
*/
|
|
@OneToMany(() => UserGroup, group => group.permissions, { nullable: true })
|
|
groups: UserGroup[]
|
|
|
|
/**
|
|
* The target
|
|
*/
|
|
@Column()
|
|
@IsNotEmpty()
|
|
@IsString()
|
|
target: string;
|
|
|
|
/**
|
|
* The action type
|
|
*/
|
|
@Column()
|
|
@IsNotEmpty()
|
|
@IsString()
|
|
action: string;
|
|
} |