feat: update device and space services to use productType instead of deviceType and add query support for device retrieval by product type

This commit is contained in:
faris Aljohari
2025-05-13 03:19:21 +03:00
parent 799fcb6fb9
commit 4aa3d04478
5 changed files with 44 additions and 9 deletions
+1 -1
View File
@@ -58,7 +58,7 @@ export class GetDevicesBySpaceOrCommunityDto {
})
@IsString()
@IsNotEmpty()
public deviceType: string;
public productType: string;
@IsUUID('4', { message: 'Invalid space UUID format' })
@IsOptional()
spaceUuid?: string;
+3 -3
View File
@@ -1729,7 +1729,7 @@ export class DeviceService {
query: GetDevicesBySpaceOrCommunityDto,
): Promise<BaseResponseDto> {
try {
const { spaceUuid, communityUuid, deviceType } = query;
const { spaceUuid, communityUuid, productType } = query;
if (!spaceUuid && !communityUuid) {
throw new BadRequestException(
'Either spaceUuid or communityUuid must be provided',
@@ -1750,12 +1750,12 @@ export class DeviceService {
}
const devicesFilterd = devices.filter(
(device) => device.productDevice?.prodType === deviceType,
(device) => device.productDevice?.prodType === productType,
);
if (devicesFilterd.length === 0) {
return new SuccessResponseDto({
message: `No ${deviceType} devices found for ${spaceUuid ? 'space' : 'community'}`,
message: `No ${productType} devices found for ${spaceUuid ? 'space' : 'community'}`,
data: [],
statusCode: HttpStatus.CREATED,
});