backend/src/models/actions/UpdateScanStation.ts

39 lines
1001 B
TypeScript

import { IsBoolean, IsInt, IsOptional, IsString } from 'class-validator';
import { ScanStation } from '../entities/ScanStation';
/**
* This class is used to update a ScanStation entity (via put request)
*/
export class UpdateScanStation {
/**
* The updated station'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 station's description.
*/
@IsString()
@IsOptional()
description?: string;
/**
* Is this station enabled?
*/
@IsBoolean()
@IsOptional()
enabled?: boolean = true;
/**
* Update a ScanStation entity based on this.
* @param station The station that shall be updated.
*/
public async updateStation(station: ScanStation): Promise<ScanStation> {
station.description = this.description;
station.enabled = this.enabled;
return station;
}
}