- Creazione di un Nuovo Catalogo (e la sua relativa pagina), a partire da un modello ed un catalogo esistente.

- Aggiunta dei bottoni sul Ccatalogocard
This commit is contained in:
Surya Paolo
2025-06-12 23:49:18 +02:00
parent 133dc6a502
commit 6b9ddc8986
7 changed files with 557 additions and 439 deletions

View File

@@ -15,7 +15,8 @@ const _ = require('lodash');
const { Catalog } = require('../models/catalog');
//GET /catalogs
const globalTables = require('../tools/globalTables');
router.post('/', auth_default, async function (req, res, next) {
const idapp = req.body.idapp;
const userId = req.body.userId;
@@ -46,4 +47,22 @@ router.get('/id/:id', async function (req, res) {
}
});
router.post('/addnew', authenticate, async function (req, res, next) {
const idapp = req.body.idapp;
const data = req.body.newCatalog;
try {
const newrecs = await globalTables.addNewCatalog(idapp, data);
if (newrecs) {
return res.send({ code: server_constants.RIS_CODE_OK, data: newrecs });
} else {
return res.send({ code: server_constants.RIS_CODE_OK, data: null });
}
} catch (e) {
console.error('Error fetching catalog by ID:', e);
return res.status(400).send({ code: server_constants.RIS_CODE_ERR, msg: e.message });
}
});
module.exports = router;