worked on the controllers
This commit is contained in:
parent
cad2d1971b
commit
7f832c0d92
@ -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
|
||||
|
@ -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],
|
||||
|
@ -36,10 +36,11 @@ const index = {
|
||||
* or middleware that are applied in order.
|
||||
*/
|
||||
get: {
|
||||
'/hello_world': [ 'controller::api:v1:Misc.hello_world' ],
|
||||
'/hello_world': ['controller::api:v1:Misc.hello_world'],
|
||||
},
|
||||
|
||||
post: {
|
||||
'/page/save': ['middleware::auth:UserOnly', 'controller::api:v1:Misc.save_page']
|
||||
|
||||
},
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user