Files
smart_grid_iot/server/src/dto/smart_device.dto.ts
T

26 lines
1.5 KiB
TypeScript

import { IsNotEmpty, IsOptional, IsString, Matches, Min, Max, MaxLength } from "class-validator";
export class SmartDeviceQueryDTO {
@IsOptional() @Min(1) page?: number = 1;
@IsOptional() @Min(1) @Max(200) pageSize?: number = 10;
@IsOptional() @IsString() @MaxLength(64) keyword?: string;
@IsOptional() @IsString() @MaxLength(64) deviceType?: string;
}
export class SmartDeviceCreateDTO {
@IsNotEmpty({ message: "设备型号不能为空" }) @IsString() @MaxLength(128) @Matches(/^[^<>]*$/) deviceModel!: string;
@IsNotEmpty({ message: "设备名称不能为空" }) @IsString() @MaxLength(128) @Matches(/^[^<>]*$/) deviceName!: string;
@IsOptional() @IsString() @MaxLength(256) @Matches(/^[^<>]*$/) deviceSpec?: string;
@IsOptional() @IsString() @MaxLength(64) @Matches(/^[^<>]*$/) deviceType?: string;
@IsOptional() @IsString() @MaxLength(2000) @Matches(/^[^<>]*$/) deviceFunction?: string;
@IsOptional() @IsString() @MaxLength(128) @Matches(/^[^<>]*$/) supplier?: string;
}
export class SmartDeviceUpdateDTO {
@IsOptional() @IsString() @MaxLength(128) @Matches(/^[^<>]*$/) deviceModel?: string;
@IsOptional() @IsString() @MaxLength(128) @Matches(/^[^<>]*$/) deviceName?: string;
@IsOptional() @IsString() @MaxLength(256) @Matches(/^[^<>]*$/) deviceSpec?: string;
@IsOptional() @IsString() @MaxLength(64) @Matches(/^[^<>]*$/) deviceType?: string;
@IsOptional() @IsString() @MaxLength(2000) @Matches(/^[^<>]*$/) deviceFunction?: string;
@IsOptional() @IsString() @MaxLength(128) @Matches(/^[^<>]*$/) supplier?: string;
}