|
|
@@ -126,10 +126,11 @@ module.exports = (crowi) => {
|
|
|
],
|
|
|
|
|
|
archive: [
|
|
|
+ body('rootPagePath').isString(),
|
|
|
body('isCommentDownload').isBoolean(),
|
|
|
body('isAttachmentFileDownload').isBoolean(),
|
|
|
body('isSubordinatedPageDownload').isBoolean(),
|
|
|
- body('fileType').isString().isIn(['pdf', 'markDown']),
|
|
|
+ body('fileType').isString().isIn(['pdf', 'markdown']),
|
|
|
body('hierarchyType').isString().isIn(['allSubordinatedPage', 'decideHierarchy']),
|
|
|
body('hierarchyValue').isNumeric(),
|
|
|
],
|
|
|
@@ -191,26 +192,69 @@ module.exports = (crowi) => {
|
|
|
return res.apiv3({ result });
|
|
|
});
|
|
|
|
|
|
+ /**
|
|
|
+ * @swagger
|
|
|
+ *
|
|
|
+ * /page/archive:
|
|
|
+ * post:
|
|
|
+ * tags: [Page]
|
|
|
+ * summary: /page/archive
|
|
|
+ * description: create page archive
|
|
|
+ * requestBody:
|
|
|
+ * content:
|
|
|
+ * application/json:
|
|
|
+ * schema:
|
|
|
+ * properties:
|
|
|
+ * rootPagePath:
|
|
|
+ * type: string
|
|
|
+ * description: path of the root page
|
|
|
+ * isCommentDownload:
|
|
|
+ * type: boolean
|
|
|
+ * description: whether archive data contains comments
|
|
|
+ * isAttachmentFileDownload:
|
|
|
+ * type: boolean
|
|
|
+ * description: whether archive data contains attachments
|
|
|
+ * isSubordinatedPageDownload:
|
|
|
+ * type: boolean
|
|
|
+ * description: whether archive data children pages
|
|
|
+ * fileType:
|
|
|
+ * type: string
|
|
|
+ * description: file type of archive data(.md, .pdf)
|
|
|
+ * hierarchyType:
|
|
|
+ * type: string
|
|
|
+ * description: method of select children pages archive data contains('allSubordinatedPage', 'decideHierarchy')
|
|
|
+ * hierarchyValue:
|
|
|
+ * type: number
|
|
|
+ * description: depth of hierarchy(use when hierarchyType is 'decideHierarchy')
|
|
|
+ * responses:
|
|
|
+ * 200:
|
|
|
+ * description: create page archive
|
|
|
+ * content:
|
|
|
+ * application/json:
|
|
|
+ * schema:
|
|
|
+ * $ref: '#/components/schemas/Page'
|
|
|
+ */
|
|
|
router.post('/archive', accessTokenParser, loginRequired, csrf, validator.archive, apiV3FormValidator, async(req, res) => {
|
|
|
+ const PageArchive = crowi.model('PageArchive');
|
|
|
|
|
|
const {
|
|
|
+ rootPagePath,
|
|
|
isCommentDownload,
|
|
|
isAttachmentFileDownload,
|
|
|
- isSubordinatedPageDownload,
|
|
|
fileType,
|
|
|
- hierarchyType,
|
|
|
- hierarchyValue,
|
|
|
} = req.body;
|
|
|
+ const owner = req.user._id;
|
|
|
|
|
|
+ const numOfPages = 1; // TODO 最終的にzipファイルに取り込むページ数を入れる
|
|
|
|
|
|
- console.log(isCommentDownload);
|
|
|
- console.log(isAttachmentFileDownload);
|
|
|
- console.log(fileType);
|
|
|
- console.log(isSubordinatedPageDownload);
|
|
|
- console.log(hierarchyType);
|
|
|
- console.log(hierarchyValue);
|
|
|
-
|
|
|
- return res.apiv3({});
|
|
|
+ await PageArchive.create({
|
|
|
+ owner,
|
|
|
+ fileType,
|
|
|
+ rootPagePath,
|
|
|
+ numOfPages,
|
|
|
+ hasComment: isCommentDownload,
|
|
|
+ hasAttachment: isAttachmentFileDownload,
|
|
|
+ });
|
|
|
});
|
|
|
|
|
|
return router;
|