pagina Attivita + Video e PDF Presentazione

This commit is contained in:
Surya Paolo
2023-01-05 01:37:20 +01:00
parent dd1c9d573f
commit f42a39d231
2 changed files with 41 additions and 2 deletions

View File

@@ -132,6 +132,8 @@ const SiteSchema = new Schema({
type: Number,
default: 0,
},
videoPromo: { type: String },
PDFPromo: { type: String },
},
confsite: {
options: { // ConfSite

View File

@@ -668,12 +668,49 @@ router.post('/getpage', async (req, res) => {
const idapp = req.body.idapp;
const mypath = params.path;
return await MyPage.findOne({ idapp, path: mypath }).then((ris) => {
return res.send({ mypage: ris });
let found = await MyPage.findOne({ idapp, path: mypath }).then((ris) => {
if (ris)
return res.send({ mypage: ris });
else
return null;
}).catch((e) => {
console.log(e.message);
res.status(400).send(e);
});
if (!found) {
// trova quelli con il :
let regexp = new RegExp(`:`, 'ig')
const searchpagesSpec = await MyPage.find({ idapp, path: { $regex: regexp } });
if (searchpagesSpec) {
let arrsubpath = mypath.split('/');
for (let i = 0; i < searchpagesSpec.length; i++) {
let arrsubstr = searchpagesSpec[i].path.split('/');
if (arrsubpath.length === arrsubpath.length) {
let mypathbuild = '';
for (let j = 0; j < arrsubstr.length; j++) {
if (arrsubstr[j].includes(':')) {
mypathbuild += arrsubpath[j] + '/';
} else {
mypathbuild += arrsubstr[j] + '/';
}
}
if (mypath + '/' === mypathbuild) {
return res.send({ mypage: searchpagesSpec[i] });
}
}
}
}
return await MyPage.findOne({ idapp, path: mypath }).then((ris) => {
return res.send({ mypage: ris });
});
}
return found;
});