Compare commits

...

4 Commits

4 changed files with 92 additions and 6 deletions

37
src/models/Permission.ts Normal file
View File

@ -0,0 +1,37 @@
import { PrimaryGeneratedColumn, Column, OneToMany, Entity } from "typeorm";
import {
IsInt,
IsNotEmpty,
IsOptional,
IsString,
} from "class-validator";
/**
* Defines the Permission interface.
*/
@Entity()
export abstract class Permission {
/**
* Autogenerated unique id (primary key).
*/
@PrimaryGeneratedColumn()
@IsOptional()
@IsInt()
id: number;
/**
* The target
*/
@Column()
@IsNotEmpty()
@IsString()
target: string;
/**
* The action type
*/
@Column()
@IsNotEmpty()
@IsString()
action: string;
}

View File

@ -1,6 +1,7 @@
import { Entity, Column, OneToMany, ManyToOne, PrimaryGeneratedColumn, Generated, Unique, JoinTable, ManyToMany } from "typeorm"; import { Entity, Column, OneToMany, ManyToOne, PrimaryGeneratedColumn, Generated, Unique, JoinTable, ManyToMany } from "typeorm";
import { IsBoolean, IsEmail, IsInt, IsNotEmpty, IsOptional, IsString, isUUID, } from "class-validator"; import { IsBoolean, IsEmail, IsInt, IsNotEmpty, IsOptional, IsString, isUUID, } from "class-validator";
import { UserGroup } from './UserGroup'; import { UserGroup } from './UserGroup';
import { Permission } from './Permission';
/** /**
* Defines a admin user. * Defines a admin user.
@ -64,11 +65,11 @@ export class User {
password: string; password: string;
/** /**
* userpermissions * permissions
*/ */
// TODO: UserPermission implementation // TODO: Permission implementation
// @OneToMany(() => UserPermission,userpermission=>) // @OneToMany(() => Permission,userpermission=>)
// userpermissions: UserPermission[]; // permissions: Permission[];
/** /**
* groups * groups

48
src/models/UserAction.ts Normal file
View File

@ -0,0 +1,48 @@
import { PrimaryGeneratedColumn, Column, OneToMany, Entity } from "typeorm";
import {
IsInt,
IsNotEmpty,
IsOptional,
IsString,
} from "class-validator";
/**
* Defines the UserAction interface.
*/
@Entity()
export class UserAction {
/**
* Autogenerated unique id (primary key).
*/
@PrimaryGeneratedColumn()
@IsOptional()
@IsInt()
id: number;
// TODO:
// user: relation
/**
* The actions's target (e.g. Track#2)
*/
@Column()
@IsNotEmpty()
@IsString()
target: string;
/**
* The actions's action (e.g. UPDATE)
*/
@Column()
@IsNotEmpty()
@IsString()
action: string;
/**
* The description of change (before-> after; e.g. distance:15->17)
*/
@Column()
@IsOptional()
@IsString()
changed: string;
}

View File

@ -5,7 +5,7 @@ import {
IsOptional, IsOptional,
IsString, IsString,
} from "class-validator"; } from "class-validator";
import { User } from "./User"; import { Permission } from "./Permission";
/** /**
* Defines the UserGroup interface. * Defines the UserGroup interface.
@ -40,5 +40,5 @@ export abstract class UserGroup {
* TODO: Something about permission stuff * TODO: Something about permission stuff
*/ */
// TODO: // TODO:
// grouppermissions: GroupPermissions[]; // grouppermissions: Permission[];
} }