Moded group updateing to a updateusergroup action model
All checks were successful
continuous-integration/drone/pr Build is passing

ref #76
This commit is contained in:
2021-01-10 18:01:22 +01:00
parent dc6ec23cb9
commit be4050768e
2 changed files with 47 additions and 7 deletions

View File

@@ -0,0 +1,39 @@
import { IsInt, IsOptional, IsString } from 'class-validator';
import { UserGroup } from '../../entities/UserGroup';
/**
* This class is used to update a UserGroup entity (via put request).
*/
export class UpdateUserGroup {
/**
* The updated group's id.
* This shouldn't have changed but it is here in case anyone ever wants to enable id changes (whyever they would want to).
*/
@IsInt()
id: number;
/**
* The updated group's name.
*/
@IsString()
name: string;
/**
* The updated groups's description.
*/
@IsString()
@IsOptional()
description?: string;
/**
* Updates a group entity based on this.
* @param group The group that shall be updated.
*/
public async update(group: UserGroup): Promise<UserGroup> {
group.name = this.name;
group.description = this.description;
return group;
}
}