mirror of
https://github.com/SyncrowIOT/backend.git
synced 2025-07-15 18:27:05 +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 {
|
static DEVICE_SPACE_COMMUNITY = class {
|
||||||
public static readonly ROUTE = 'devices/recursive-child';
|
public static readonly ROUTE = 'devices-space-community';
|
||||||
|
|
||||||
static ACTIONS = class {
|
static ACTIONS = class {
|
||||||
public static readonly GET_ALL_DEVICES_BY_SPACE_OR_COMMUNITY_WITH_RECURSIVE_CHILD_SUMMARY =
|
public static readonly GET_ALL_DEVICES_BY_SPACE_OR_COMMUNITY_WITH_RECURSIVE_CHILD_SUMMARY =
|
||||||
'Get all devices by space or community with recursive child';
|
'Get all devices by space or community with recursive child';
|
||||||
|
|
||||||
public static readonly GET_ALL_DEVICES_BY_SPACE_OR_COMMUNITY_WITH_RECURSIVE_CHILD_DESCRIPTION =
|
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.';
|
'This endpoint retrieves all devices in the system by space or community with recursive child.';
|
||||||
};
|
};
|
||||||
|
@ -23,7 +23,7 @@ export class DeviceSpaceOrCommunityController {
|
|||||||
@ApiBearerAuth()
|
@ApiBearerAuth()
|
||||||
@UseGuards(PermissionsGuard)
|
@UseGuards(PermissionsGuard)
|
||||||
@Permissions('DEVICE_VIEW')
|
@Permissions('DEVICE_VIEW')
|
||||||
@Get()
|
@Get('recursive-child')
|
||||||
@ApiOperation({
|
@ApiOperation({
|
||||||
summary:
|
summary:
|
||||||
ControllerRoute.DEVICE_SPACE_COMMUNITY.ACTIONS
|
ControllerRoute.DEVICE_SPACE_COMMUNITY.ACTIONS
|
||||||
|
@ -6,6 +6,7 @@ import {
|
|||||||
IsOptional,
|
IsOptional,
|
||||||
IsString,
|
IsString,
|
||||||
IsUUID,
|
IsUUID,
|
||||||
|
ValidateIf,
|
||||||
} from 'class-validator';
|
} from 'class-validator';
|
||||||
|
|
||||||
export class GetDeviceBySpaceUuidDto {
|
export class GetDeviceBySpaceUuidDto {
|
||||||
@ -66,4 +67,8 @@ export class GetDevicesBySpaceOrCommunityDto {
|
|||||||
@IsUUID('4', { message: 'Invalid community UUID format' })
|
@IsUUID('4', { message: 'Invalid community UUID format' })
|
||||||
@IsOptional()
|
@IsOptional()
|
||||||
communityUuid?: string;
|
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