98 lines
1.9 KiB
TypeScript
98 lines
1.9 KiB
TypeScript
import {
|
|
IsArray,
|
|
IsBoolean,
|
|
|
|
IsOptional,
|
|
IsString
|
|
} from "class-validator";
|
|
import { Permission } from '../entities/Permission';
|
|
import { User } from '../entities/User';
|
|
import { UserGroup } from '../entities/UserGroup';
|
|
import { ResponsePrincipal } from './ResponsePrincipal';
|
|
|
|
/**
|
|
* Defines the user response.
|
|
*/
|
|
export class ResponseUser extends ResponsePrincipal {
|
|
/**
|
|
* The user's first name.
|
|
*/
|
|
@IsString()
|
|
firstname: string;
|
|
|
|
/**
|
|
* The user's middle name.
|
|
*/
|
|
@IsString()
|
|
middlename?: string;
|
|
|
|
/**
|
|
* The user's last name.
|
|
*/
|
|
@IsString()
|
|
lastname: string;
|
|
|
|
/**
|
|
* The user's phone number.
|
|
*/
|
|
@IsString()
|
|
phone?: string;
|
|
|
|
/**
|
|
* The user's e-mail address.
|
|
*/
|
|
@IsString()
|
|
email?: string;
|
|
|
|
/**
|
|
* The user's username.
|
|
*/
|
|
@IsString()
|
|
username?: string;
|
|
|
|
/**
|
|
* Is user enabled?
|
|
*/
|
|
@IsBoolean()
|
|
enabled: boolean = true;
|
|
|
|
/**
|
|
* The user's profile pic.
|
|
*/
|
|
@IsString()
|
|
@IsOptional()
|
|
profilePic?: string;
|
|
|
|
/**
|
|
* The groups that the user is a part of.
|
|
*/
|
|
@IsArray()
|
|
@IsOptional()
|
|
groups: UserGroup[];
|
|
|
|
/**
|
|
* The user's permissions.
|
|
*/
|
|
@IsArray()
|
|
@IsOptional()
|
|
permissions: Permission[];
|
|
|
|
/**
|
|
* Creates a ResponseUser object from a user.
|
|
* @param user The user the response shall be build for.
|
|
*/
|
|
public constructor(user: User) {
|
|
super(user);
|
|
this.firstname = user.firstname;
|
|
this.middlename = user.middlename;
|
|
this.lastname = user.lastname;
|
|
this.phone = user.phone;
|
|
this.email = user.email;
|
|
this.username = user.username;
|
|
this.enabled = user.enabled;
|
|
this.profilePic = user.profilePic;
|
|
this.groups = user.groups;
|
|
this.permissions = user.permissions;
|
|
}
|
|
}
|