Added responseusers

ref #6
This commit is contained in:
2020-12-17 21:12:45 +01:00
parent cc5a30980a
commit efecffb72d
2 changed files with 120 additions and 14 deletions

View File

@@ -0,0 +1,94 @@
import {
IsArray,
IsBoolean,
IsInt,
IsOptional,
IsString
} from "class-validator";
import { Permission } from '../entities/Permission';
import { User } from '../entities/User';
import { UserGroup } from '../entities/UserGroup';
/**
* Defines a user response.
*/
export class ResponseUser {
/**
* Autogenerated unique id (primary key).
*/
@IsInt()
id: number;;
/**
* The user's first name.
*/
@IsString()
firstname: string;
/**
* The user's middle name.
* Optional.
*/
@IsString()
middlename?: string;
/**
* The user's last name.
*/
@IsString()
lastname: string;
/**
* The user's phone number.
* Optional.
*/
@IsString()
phone?: string;
/**
* The user's e-mail address.
* Optional.
*/
@IsString()
email?: string;
/**
* is user enabled?
*/
@IsBoolean()
enabled: boolean = true;
/**
* profilepic
*/
@IsString()
@IsOptional()
profilePic?: string;
/**
* Groups
*/
@IsArray()
@IsOptional()
groups: UserGroup[];
/**
* permissions
*/
@IsArray()
@IsOptional()
permissions: Permission[];
public constructor(user: User) {
this.id = user.id;
this.firstname = user.firstname;
this.middlename = user.middlename;
this.lastname = user.lastname;
this.phone = user.phone;
this.email = user.email;
this.enabled = user.enabled;
this.profilePic = user.profilePic;
this.groups = user.groups;
this.permissions = user.permissions;
}
}