update device
This commit is contained in:
@@ -43,7 +43,8 @@ class DeviceController {
|
|||||||
return res.status(400).json(setResponse(errors, 'Validation failed', 400));
|
return res.status(400).json(setResponse(errors, 'Validation failed', 400));
|
||||||
}
|
}
|
||||||
|
|
||||||
const newDevice = await DeviceService.createDevice(value, req.user.userId);
|
const newDevice = await DeviceService.createDevice(value, req.user.user_id);
|
||||||
|
|
||||||
return res.status(201).json(
|
return res.status(201).json(
|
||||||
setResponse(newDevice, 'Device created successfully', 201)
|
setResponse(newDevice, 'Device created successfully', 201)
|
||||||
);
|
);
|
||||||
@@ -69,7 +70,7 @@ class DeviceController {
|
|||||||
return res.status(400).json(setResponse(errors, 'Validation failed', 400));
|
return res.status(400).json(setResponse(errors, 'Validation failed', 400));
|
||||||
}
|
}
|
||||||
|
|
||||||
const updatedDevice = await DeviceService.updateDevice(id, value, req.user.userId);
|
const updatedDevice = await DeviceService.updateDevice(id, value, req.user.user_Id);
|
||||||
|
|
||||||
return res.status(200).json(
|
return res.status(200).json(
|
||||||
setResponse(updatedDevice.data, 'Device updated successfully', 200)
|
setResponse(updatedDevice.data, 'Device updated successfully', 200)
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ class DeviceService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Update device
|
// Update device
|
||||||
static async updateDevice(id, data, userId) {
|
static async updateDevice(id, data, user_Id) {
|
||||||
if (!data || typeof data !== 'object') data = {};
|
if (!data || typeof data !== 'object') data = {};
|
||||||
|
|
||||||
const existingDevice = await getDeviceByIdDb(id);
|
const existingDevice = await getDeviceByIdDb(id);
|
||||||
@@ -57,7 +57,7 @@ class DeviceService {
|
|||||||
throw new ErrorHandler(404, 'Device not found');
|
throw new ErrorHandler(404, 'Device not found');
|
||||||
}
|
}
|
||||||
|
|
||||||
data.updated_by = userId;
|
data.updated_by = user_Id;
|
||||||
|
|
||||||
const updatedDevice = await updateDeviceDb(id, data);
|
const updatedDevice = await updateDeviceDb(id, data);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user