backend/src/models/entities/Permission.ts

49 lines
837 B
TypeScript

import {
IsInt,
IsNotEmpty,
IsString
} from "class-validator";
import { Column, Entity, OneToMany, PrimaryGeneratedColumn } from "typeorm";
import { User } from './User';
import { UserGroup } from './UserGroup';
/**
* Defines the Permission interface.
*/
@Entity()
export abstract class Permission {
/**
* Autogenerated unique id (primary key).
*/
@PrimaryGeneratedColumn()
@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;
}