mirror of
https://github.com/SyncrowIOT/backend.git
synced 2026-10-24 21:07:54 +00:00
75 lines
1.6 KiB
TypeScript
75 lines
1.6 KiB
TypeScript
import { DeviceTypeEnum } from '@app/common/constants/device-type.enum';
|
|
import { ApiProperty } from '@nestjs/swagger';
|
|
import {
|
|
IsEnum,
|
|
IsNotEmpty,
|
|
IsOptional,
|
|
IsString,
|
|
IsUUID,
|
|
ValidateIf,
|
|
} from 'class-validator';
|
|
|
|
export class GetDeviceBySpaceUuidDto {
|
|
@ApiProperty({
|
|
description: 'spaceUuid',
|
|
required: true,
|
|
})
|
|
@IsString()
|
|
@IsNotEmpty()
|
|
public spaceUuid: string;
|
|
}
|
|
export class GetDeviceLogsDto {
|
|
@ApiProperty({
|
|
description: 'code',
|
|
required: true,
|
|
})
|
|
@IsString()
|
|
@IsNotEmpty()
|
|
public code: string;
|
|
@ApiProperty({
|
|
description: 'startTime',
|
|
required: false,
|
|
})
|
|
@IsString()
|
|
@IsOptional()
|
|
public startTime: string;
|
|
@ApiProperty({
|
|
description: 'endTime',
|
|
required: false,
|
|
})
|
|
@IsString()
|
|
@IsOptional()
|
|
public endTime: string;
|
|
}
|
|
export class GetDoorLockDevices {
|
|
@ApiProperty({
|
|
description: 'Device Type',
|
|
enum: DeviceTypeEnum,
|
|
required: false,
|
|
})
|
|
@IsEnum(DeviceTypeEnum)
|
|
@IsOptional()
|
|
public deviceType: DeviceTypeEnum;
|
|
}
|
|
export class GetDevicesBySpaceOrCommunityDto {
|
|
@ApiProperty({
|
|
description: 'Device Product Type',
|
|
example: 'PC',
|
|
required: true,
|
|
})
|
|
@IsString()
|
|
@IsNotEmpty()
|
|
public productType: string;
|
|
@IsUUID('4', { message: 'Invalid space UUID format' })
|
|
@IsOptional()
|
|
spaceUuid?: string;
|
|
|
|
@IsUUID('4', { message: 'Invalid community UUID format' })
|
|
@IsOptional()
|
|
communityUuid?: string;
|
|
|
|
@ValidateIf((o) => !o.spaceUuid && !o.communityUuid)
|
|
@IsNotEmpty({ message: 'Either spaceUuid or communityUuid must be provided' })
|
|
requireEither?: never; // This ensures at least one of them is provided
|
|
}
|