2020-02-08 08:39:33 +00:00
|
|
|
const Controller = require('libflitter/controller/Controller')
|
2020-02-08 11:06:18 +00:00
|
|
|
const { ObjectId } = require("mongodb");
|
|
|
|
const Page = require("../../../models/api/Page.model")
|
2020-02-08 08:39:33 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Misc Controller
|
|
|
|
* -------------------------------------------------------------
|
|
|
|
* Put some description here!
|
|
|
|
*/
|
|
|
|
class Misc extends Controller {
|
|
|
|
|
|
|
|
hello_world(req, res) {
|
|
|
|
return res.api({
|
|
|
|
hello: 'world',
|
|
|
|
})
|
|
|
|
}
|
2020-02-08 11:06:18 +00:00
|
|
|
|
|
|
|
async save_page(req, res) {
|
|
|
|
// return res.status(400).message('Missing required field: some_field').api({})
|
|
|
|
|
|
|
|
// Name, Parent, originalID
|
|
|
|
requried_fields = {
|
|
|
|
Name: String,
|
|
|
|
Parent: ObjectId,
|
|
|
|
OriginalId: ObjectId
|
|
|
|
}
|
|
|
|
|
|
|
|
requried_fields.name = req.name
|
|
|
|
requried_fields.Parrent = req.Parrent
|
|
|
|
requried_fields.OriginalId = req.OriginalId
|
|
|
|
|
|
|
|
if (!requried_fields.Name) {
|
|
|
|
return res.status(400).message('Missing required field: Name').api({})
|
|
|
|
} else if (!requried_fields.Parrent) {
|
|
|
|
return res.status(400).message('Missing required field: Parent').api({})
|
|
|
|
|
|
|
|
} else if (!requried_fields.ObjectId) {
|
|
|
|
return res.status(400).message('Missing required field: ObjectId').api({})
|
|
|
|
}
|
|
|
|
|
|
|
|
if (req.body.PageId) {
|
|
|
|
//use the page model to find by id and
|
|
|
|
const page = await Page.findById(req.body.PageId)
|
|
|
|
if (!page) {
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2020-02-08 08:39:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = exports = Misc
|