import { SuccessResponse } from './base'; import { IsBoolean, IsInt, IsNotEmpty, IsOptional, IsString, Min } from 'class-validator'; import { ValidateConstructor } from '../utils'; @ValidateConstructor export class GetRootResponse extends SuccessResponse { constructor(rootId: number) { super(); this.rootId = rootId; } @IsInt() @Min(1) rootId: number; } export class GetNodeResponse extends SuccessResponse { constructor( id: number, name: string, isFile: boolean, parent: number | null ) { super(); this.id = id; this.name = name; this.isFile = isFile; this.parent = parent; } @IsInt() @Min(1) id: number; @IsNotEmpty() name: string; @IsBoolean() isFile: boolean; @IsOptional() @IsInt() @Min(1) parent: number | null; @IsOptional() @IsInt({ each: true }) @Min(1, { each: true }) children?: number[]; @IsOptional() @IsInt() @Min(0) size?: number; } @ValidateConstructor export class GetPathResponse extends SuccessResponse { constructor(path: string) { super(); this.path = path; } @IsNotEmpty() @IsString() path: string; } @ValidateConstructor export class CreateFolderResponse extends SuccessResponse { constructor(id: number) { super(); this.id = id; } @IsInt() @Min(1) id: number; } export class UploadFileResponse extends SuccessResponse {} export class DeleteResponse extends SuccessResponse {} export class CreateFileResponse extends CreateFolderResponse {}