|
@@ -1,18 +1,37 @@
|
|
|
|
|
+const debug = require('debug')('crowi-plugin:lsx:routes:lsx');
|
|
|
|
|
+const OptionParser = require('../util/option-parser');
|
|
|
|
|
+
|
|
|
|
|
+class Lsx {
|
|
|
|
|
+
|
|
|
|
|
+ static addDepthCondition(query, optionDepth) {
|
|
|
|
|
+ return query.and({
|
|
|
|
|
+ // TODO implement
|
|
|
|
|
+ // path: new RegExp('...')
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
module.exports = (crowi, app) => {
|
|
module.exports = (crowi, app) => {
|
|
|
- var debug = require('debug')('crowi-plugin:lsx:routes:lsx')
|
|
|
|
|
- , Page = crowi.model('Page')
|
|
|
|
|
|
|
+ var Page = crowi.model('Page')
|
|
|
, ApiResponse = crowi.require('../util/apiResponse')
|
|
, ApiResponse = crowi.require('../util/apiResponse')
|
|
|
, actions = {};
|
|
, actions = {};
|
|
|
|
|
|
|
|
actions.listPages = (req, res) => {
|
|
actions.listPages = (req, res) => {
|
|
|
let user = req.user;
|
|
let user = req.user;
|
|
|
let pagePath = req.query.pagePath;
|
|
let pagePath = req.query.pagePath;
|
|
|
- let queryOptions = req.query.queryOptions;
|
|
|
|
|
|
|
+ let options = JSON.parse(req.query.options);
|
|
|
|
|
|
|
|
// find pages
|
|
// find pages
|
|
|
- Page.generateQueryToListByStartWith(pagePath, user, queryOptions)
|
|
|
|
|
- .populate('revision', '-body') // exclude body
|
|
|
|
|
- .exec()
|
|
|
|
|
|
|
+ let query = Page.generateQueryToListByStartWith(pagePath, user, {})
|
|
|
|
|
+ .populate('revision', '-body'); // exclude body
|
|
|
|
|
+
|
|
|
|
|
+ // depth
|
|
|
|
|
+ if (options.depth !== undefined) {
|
|
|
|
|
+ query = Lsx.addDepthCondition(query, options.depth);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ query.exec()
|
|
|
.then((pages) => {
|
|
.then((pages) => {
|
|
|
res.json(ApiResponse.success({pages}));
|
|
res.json(ApiResponse.success({pages}));
|
|
|
})
|
|
})
|