new version Visualizzazione Service

This commit is contained in:
Surya Paolo
2023-04-04 15:26:56 +02:00
parent 6d1ad4132f
commit 8a77dabc22
8 changed files with 198 additions and 63 deletions

View File

@@ -1436,4 +1436,43 @@ router.post('/mgt', authenticate, async (req, res) => {
});
router.post('/cmd', authenticate, async (req, res) => {
const mydata = req.body.mydata;
const idapp = req.body.idapp;
const cmd = req.body.cmd;
const id = req.body.id;
const tab = req.body.tab;
const value = req.body.value;
try {
const username = req.user.username;
let ris = null;
if (cmd === shared_consts.CMD_USER.SET_FAVORITE) {
if (value)
ris = await User.addFavorite(idapp, username, id, tab);
else
ris = await User.removeFavorite(idapp, username, id, tab);
} else if (cmd === shared_consts.CMD_USER.SET_BOOKMARK) {
if (value)
ris = await User.addBookmark(idapp, username, id, tab);
else
ris = await User.removeBookmark(idapp, username, id, tab);
}
let state = (value && ris && ris.ok === 1) ? 1 : ((!value && ris && ris.ok === 1) ? -1 : 0);
return res.send({ state });
} catch (e) {
res.status(400).send();
res.send({ code: server_constants.RIS_CODE_ERR, msg: e });
console.log(e.message);
}
});
module.exports = router;