worked on the controllers

This commit is contained in:
Thomas Atkins 2020-02-08 05:06:18 -06:00
parent cad2d1971b
commit 7f832c0d92
3 changed files with 38 additions and 2 deletions

View File

@ -1,4 +1,6 @@
const Controller = require('libflitter/controller/Controller')
const { ObjectId } = require("mongodb");
const Page = require("../../../models/api/Page.model")
/*
* Misc Controller
@ -12,6 +14,39 @@ class Misc extends Controller {
hello: 'world',
})
}
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) {
}
}
}
}
module.exports = exports = Misc

View File

@ -15,7 +15,7 @@ class Page extends Model {
return {
Name: String,
OrgUserId: ObjectId,
IsPublic: Boolean,
IsPublic: { type: Boolean, default: true },
IsVisibleInMenu: { type: Boolean, default: true },
ParentId: ObjectId,
NodeIds: [ObjectId],

View File

@ -40,6 +40,7 @@ const index = {
},
post: {
'/page/save': ['middleware::auth:UserOnly', 'controller::api:v1:Misc.save_page']
},
}