pagina Attivita + Video e PDF Presentazione
This commit is contained in:
@@ -132,6 +132,8 @@ const SiteSchema = new Schema({
|
|||||||
type: Number,
|
type: Number,
|
||||||
default: 0,
|
default: 0,
|
||||||
},
|
},
|
||||||
|
videoPromo: { type: String },
|
||||||
|
PDFPromo: { type: String },
|
||||||
},
|
},
|
||||||
confsite: {
|
confsite: {
|
||||||
options: { // ConfSite
|
options: { // ConfSite
|
||||||
|
|||||||
@@ -668,12 +668,49 @@ router.post('/getpage', async (req, res) => {
|
|||||||
const idapp = req.body.idapp;
|
const idapp = req.body.idapp;
|
||||||
const mypath = params.path;
|
const mypath = params.path;
|
||||||
|
|
||||||
return await MyPage.findOne({ idapp, path: mypath }).then((ris) => {
|
let found = await MyPage.findOne({ idapp, path: mypath }).then((ris) => {
|
||||||
return res.send({ mypage: ris });
|
if (ris)
|
||||||
|
return res.send({ mypage: ris });
|
||||||
|
else
|
||||||
|
return null;
|
||||||
}).catch((e) => {
|
}).catch((e) => {
|
||||||
console.log(e.message);
|
console.log(e.message);
|
||||||
res.status(400).send(e);
|
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;
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user