mirror of
https://github.com/SyncrowIOT/backend.git
synced 2025-07-15 10:25:23 +00:00
Merge pull request #372 from SyncrowIOT/fix-get-devices-by-product-type
feat: update DEVICE_SPACE_COMMUNITY route and add validation for spaceUuid and communityUuid in DTO
This commit is contained in:
@ -625,10 +625,12 @@ export class ControllerRoute {
|
||||
};
|
||||
};
|
||||
static DEVICE_SPACE_COMMUNITY = class {
|
||||
public static readonly ROUTE = 'devices/recursive-child';
|
||||
public static readonly ROUTE = 'devices-space-community';
|
||||
|
||||
static ACTIONS = class {
|
||||
public static readonly GET_ALL_DEVICES_BY_SPACE_OR_COMMUNITY_WITH_RECURSIVE_CHILD_SUMMARY =
|
||||
'Get all devices by space or community with recursive child';
|
||||
|
||||
public static readonly GET_ALL_DEVICES_BY_SPACE_OR_COMMUNITY_WITH_RECURSIVE_CHILD_DESCRIPTION =
|
||||
'This endpoint retrieves all devices in the system by space or community with recursive child.';
|
||||
};
|
||||
|
@ -23,7 +23,7 @@ export class DeviceSpaceOrCommunityController {
|
||||
@ApiBearerAuth()
|
||||
@UseGuards(PermissionsGuard)
|
||||
@Permissions('DEVICE_VIEW')
|
||||
@Get()
|
||||
@Get('recursive-child')
|
||||
@ApiOperation({
|
||||
summary:
|
||||
ControllerRoute.DEVICE_SPACE_COMMUNITY.ACTIONS
|
||||
|
@ -6,6 +6,7 @@ import {
|
||||
IsOptional,
|
||||
IsString,
|
||||
IsUUID,
|
||||
ValidateIf,
|
||||
} from 'class-validator';
|
||||
|
||||
export class GetDeviceBySpaceUuidDto {
|
||||
@ -66,4 +67,8 @@ export class GetDevicesBySpaceOrCommunityDto {
|
||||
@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
|
||||
}
|
||||
|
Reference in New Issue
Block a user