mirror of
https://github.com/SyncrowIOT/backend.git
synced 2025-07-15 10:25:23 +00:00
Refactor code to remove duplicate code and improve readability
This commit is contained in:
@ -103,7 +103,6 @@ export class DeviceService {
|
|||||||
const devicesData = await Promise.all(
|
const devicesData = await Promise.all(
|
||||||
devices.map(async (device) => {
|
devices.map(async (device) => {
|
||||||
return {
|
return {
|
||||||
uuid: device.uuid,
|
|
||||||
haveRoom: device.spaceDevice ? true : false,
|
haveRoom: device.spaceDevice ? true : false,
|
||||||
productUuid: device.productDevice.uuid,
|
productUuid: device.productDevice.uuid,
|
||||||
productType: device.productDevice.prodType,
|
productType: device.productDevice.prodType,
|
||||||
@ -111,6 +110,7 @@ export class DeviceService {
|
|||||||
...(await this.getDeviceDetailsByDeviceIdTuya(
|
...(await this.getDeviceDetailsByDeviceIdTuya(
|
||||||
device.deviceTuyaUuid,
|
device.deviceTuyaUuid,
|
||||||
)),
|
)),
|
||||||
|
uuid: device.uuid,
|
||||||
} as GetDeviceDetailsInterface;
|
} as GetDeviceDetailsInterface;
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
@ -149,7 +149,6 @@ export class DeviceService {
|
|||||||
const devicesData = await Promise.all(
|
const devicesData = await Promise.all(
|
||||||
devices.map(async (device) => {
|
devices.map(async (device) => {
|
||||||
return {
|
return {
|
||||||
uuid: device.uuid,
|
|
||||||
haveRoom: device.spaceDevice ? true : false,
|
haveRoom: device.spaceDevice ? true : false,
|
||||||
productUuid: device.productDevice.uuid,
|
productUuid: device.productDevice.uuid,
|
||||||
productType: device.productDevice.prodType,
|
productType: device.productDevice.prodType,
|
||||||
@ -157,6 +156,7 @@ export class DeviceService {
|
|||||||
...(await this.getDeviceDetailsByDeviceIdTuya(
|
...(await this.getDeviceDetailsByDeviceIdTuya(
|
||||||
device.deviceTuyaUuid,
|
device.deviceTuyaUuid,
|
||||||
)),
|
)),
|
||||||
|
uuid: device.uuid,
|
||||||
} as GetDeviceDetailsInterface;
|
} as GetDeviceDetailsInterface;
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
@ -303,8 +303,6 @@ export class UnitService {
|
|||||||
type: updatedUnit.spaceType.type,
|
type: updatedUnit.spaceType.type,
|
||||||
};
|
};
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log('err', err);
|
|
||||||
|
|
||||||
if (err instanceof BadRequestException) {
|
if (err instanceof BadRequestException) {
|
||||||
throw err;
|
throw err;
|
||||||
} else {
|
} else {
|
||||||
|
Reference in New Issue
Block a user