Răsfoiți Sursa

add req.query.pageLimitationS

zahmis 5 ani în urmă
părinte
comite
11a5410091
1 a modificat fișierele cu 2 adăugiri și 5 ștergeri
  1. 2 5
      src/server/routes/apiv3/attachment.js

+ 2 - 5
src/server/routes/apiv3/attachment.js

@@ -23,12 +23,10 @@ module.exports = (crowi) => {
   const Attachment = crowi.model('Attachment');
   const Attachment = crowi.model('Attachment');
   const apiV3FormValidator = require('../../middlewares/apiv3-form-validator')(crowi);
   const apiV3FormValidator = require('../../middlewares/apiv3-form-validator')(crowi);
 
 
-
   const validator = {
   const validator = {
     retrieveAttachments: [
     retrieveAttachments: [
       query('pageId').isMongoId().withMessage('pageId is required'),
       query('pageId').isMongoId().withMessage('pageId is required'),
-      // query('pagingLimit').isInt({ min: 1 }).isInt({ max: 1000 }), // temp data
-      // query('offset').isInt({ min: 0 }),
+      query('pageLimitationS').isInt({ max: 100 }),
     ],
     ],
   };
   };
   /**
   /**
@@ -51,7 +49,6 @@ module.exports = (crowi) => {
    */
    */
   router.get('/list', accessTokenParser, loginRequired, validator.retrieveAttachments, apiV3FormValidator, async(req, res) => {
   router.get('/list', accessTokenParser, loginRequired, validator.retrieveAttachments, apiV3FormValidator, async(req, res) => {
 
 
-
     try {
     try {
       const pageId = req.query.pageId;
       const pageId = req.query.pageId;
       // check whether accessible
       // check whether accessible
@@ -62,7 +59,7 @@ module.exports = (crowi) => {
       }
       }
 
 
       // directly get paging-size from db. not to delivery from client side.
       // directly get paging-size from db. not to delivery from client side.
-      const pageLimitationS = await crowi.configManager.getConfig('crowi', 'customize:showPageLimitationS') || 10;
+      const pageLimitationS = req.query.pageLimitationS || await crowi.configManager.getConfig('crowi', 'customize:showPageLimitationS') || 10;
       const selectedPage = req.query.selectedPage;
       const selectedPage = req.query.selectedPage;
       const offset = (selectedPage - 1) * pageLimitationS;
       const offset = (selectedPage - 1) * pageLimitationS;
       const paginateResult = await Attachment.paginate(
       const paginateResult = await Attachment.paginate(