fileserver/dto/responses/fs.ts

90 lines
1.4 KiB
TypeScript
Raw Normal View History

2022-08-25 12:16:29 +00:00
import { SuccessResponse } from './base';
2022-08-25 13:13:44 +00:00
import {
IsBoolean,
IsInt,
IsNotEmpty,
IsOptional,
IsString,
Min
} from 'class-validator';
import { ValidateConstructor } from '../utils';
2022-08-25 13:13:44 +00:00
@ValidateConstructor
2022-08-25 12:16:29 +00:00
export class GetRootResponse extends SuccessResponse {
2022-08-25 13:13:44 +00:00
constructor(rootId: number) {
super();
this.rootId = rootId;
}
2022-08-25 11:39:58 +00:00
@IsInt()
@Min(1)
rootId: number;
}
2022-08-25 12:16:29 +00:00
export class GetNodeResponse extends SuccessResponse {
2022-08-25 13:13:44 +00:00
constructor(
id: number,
name: string,
isFile: boolean,
parent: number | null
) {
super();
this.id = id;
this.name = name;
this.isFile = isFile;
this.parent = parent;
}
2022-08-25 11:39:58 +00:00
@IsInt()
@Min(1)
id: number;
2022-08-25 11:39:58 +00:00
2022-08-25 13:22:14 +00:00
@IsString()
name: string;
2022-08-25 11:39:58 +00:00
@IsBoolean()
isFile: boolean;
2022-08-25 11:39:58 +00:00
2022-08-25 13:13:44 +00:00
@IsOptional()
@IsInt()
@Min(1)
parent: number | null;
2022-08-25 11:39:58 +00:00
2022-08-25 13:13:44 +00:00
@IsOptional()
2022-08-25 12:16:29 +00:00
@IsInt({ each: true })
@Min(1, { each: true })
children?: number[];
2022-08-25 11:39:58 +00:00
2022-08-25 13:13:44 +00:00
@IsOptional()
@IsInt()
@Min(0)
size?: number;
}
2022-08-25 13:13:44 +00:00
@ValidateConstructor
2022-08-25 12:16:29 +00:00
export class GetPathResponse extends SuccessResponse {
2022-08-25 13:13:44 +00:00
constructor(path: string) {
super();
this.path = path;
}
2022-08-25 11:39:58 +00:00
@IsNotEmpty()
2022-08-25 13:13:44 +00:00
@IsString()
path: string;
}
2022-08-25 13:13:44 +00:00
@ValidateConstructor
2022-08-25 12:16:29 +00:00
export class CreateFolderResponse extends SuccessResponse {
2022-08-25 13:13:44 +00:00
constructor(id: number) {
super();
this.id = id;
}
2022-08-25 11:39:58 +00:00
@IsInt()
@Min(1)
id: number;
}
2022-08-25 13:13:44 +00:00
export class UploadFileResponse extends SuccessResponse {}
export class DeleteResponse extends SuccessResponse {}
export class CreateFileResponse extends CreateFolderResponse {}