update
This commit is contained in:
@@ -216,11 +216,12 @@ module.exports.updateInstalled = [
|
||||
],
|
||||
checkValidations(validationResult),
|
||||
async (req, res) => {
|
||||
console.log('updateInstalled ******************', req.params.id, req.params.type)
|
||||
const installedDevice = await InstalledDevice.findById(req.params.id)
|
||||
if (!installedDevice) {
|
||||
return res.status(404).json({ msg: 'این ایدی وجود ندارد' })
|
||||
} else {
|
||||
try {
|
||||
console.log('updateInstalled ******************', req.params.id, req.params.type)
|
||||
const installedDevice = await InstalledDevice.findById(req.params.id)
|
||||
if (!installedDevice) {
|
||||
return res.status(404).json({ msg: 'این ایدی وجود ندارد' })
|
||||
}
|
||||
console.log('installedDevice ******************')
|
||||
// const user = await User.findById(installedDevice.userId).select('walletBalance score totalScore')
|
||||
switch (req.params.type) {
|
||||
@@ -271,7 +272,7 @@ module.exports.updateInstalled = [
|
||||
console.log('userGPS updated ******************')
|
||||
}
|
||||
|
||||
await Score.delete({ deviceId: installedDevice.id })
|
||||
await Score.deleteMany({ deviceId: installedDevice.id })
|
||||
console.log('Score deleted ******************')
|
||||
|
||||
notifyAdmin('newInstallDeviceRequest', installedDevice.userId)
|
||||
@@ -284,6 +285,9 @@ module.exports.updateInstalled = [
|
||||
break
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error in updateInstalled:', error?.message)
|
||||
return res.status(500).json({ msg: 'خطا در بهروزرسانی وضعیت دستگاه' })
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user