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