43 lines
758 B
TypeScript
43 lines
758 B
TypeScript
import {
|
|
IsInt,
|
|
IsNotEmpty,
|
|
IsOptional,
|
|
IsString
|
|
} from "class-validator";
|
|
import { Column, Entity, ManyToOne, PrimaryGeneratedColumn } from "typeorm";
|
|
import { Permission } from "./Permission";
|
|
|
|
/**
|
|
* Defines the UserGroup interface.
|
|
*/
|
|
@Entity()
|
|
export class UserGroup {
|
|
/**
|
|
* Autogenerated unique id (primary key).
|
|
*/
|
|
@PrimaryGeneratedColumn()
|
|
@IsInt()
|
|
id: number;
|
|
|
|
/**
|
|
* permissions
|
|
*/
|
|
@ManyToOne(() => Permission, permission => permission.groups, { nullable: true })
|
|
permissions: Permission[];
|
|
|
|
/**
|
|
* The group's name
|
|
*/
|
|
@Column()
|
|
@IsNotEmpty()
|
|
@IsString()
|
|
name: string;
|
|
|
|
/**
|
|
* The group's description
|
|
*/
|
|
@Column({ nullable: true })
|
|
@IsOptional()
|
|
@IsString()
|
|
description?: string;
|
|
} |