|
|
@@ -2,6 +2,7 @@ module.exports = function(crowi, app) {
|
|
|
'use strict';
|
|
|
|
|
|
const Tag = crowi.model('Tag');
|
|
|
+ const PageTagRelation = crowi.model('PageTagRelation');
|
|
|
const ApiResponse = require('../util/apiResponse');
|
|
|
const actions = {};
|
|
|
const api = {};
|
|
|
@@ -11,7 +12,7 @@ module.exports = function(crowi, app) {
|
|
|
|
|
|
/**
|
|
|
* @api {get} /tags.search search tags
|
|
|
- * @apiName searchTag
|
|
|
+ * @apiName SearchTag
|
|
|
* @apiGroup Tag
|
|
|
*
|
|
|
* @apiParam {String} q keyword
|
|
|
@@ -22,5 +23,18 @@ module.exports = function(crowi, app) {
|
|
|
return res.json(ApiResponse.success({tags}));
|
|
|
};
|
|
|
|
|
|
+ /**
|
|
|
+ * @api {get} /tags.get get page tags
|
|
|
+ * @apiName GetTag
|
|
|
+ * @apiGroup Tag
|
|
|
+ *
|
|
|
+ * @apiParam {String} pageId
|
|
|
+ */
|
|
|
+ api.get = async function(req, res) {
|
|
|
+ let tags = await PageTagRelation.find({relatedPage: req.query.pageId}).populate('relatedTag').select('-_id relatedTag');
|
|
|
+ tags = tags.map(tag => tag.relatedTag.name);
|
|
|
+ return res.json(ApiResponse.success({tags}));
|
|
|
+ };
|
|
|
+
|
|
|
return actions;
|
|
|
};
|