Przeglądaj źródła

change /selected-status-users/ to /search-user-status/ and change line position for clearlooking

ryuichi-e 6 lat temu
rodzic
commit
b2fced73af
1 zmienionych plików z 44 dodań i 44 usunięć
  1. 44 44
      src/server/routes/apiv3/users.js

+ 44 - 44
src/server/routes/apiv3/users.js

@@ -118,6 +118,50 @@ module.exports = (crowi) => {
     }
   });
 
+  const statusNo = {
+    registered: User.STATUS_REGISTERED,
+    active: User.STATUS_ACTIVE,
+    suspended: User.STATUS_SUSPENDED,
+    invited: User.STATUS_INVITED,
+  };
+
+  validator.statusList = [
+    body('statusList').custom((value) => {
+      const error = [];
+      value.forEach((status) => {
+        if (!Object.keys(statusNo)) {
+          error.push(status);
+        }
+      });
+      return (error.length === 0);
+    }),
+  ];
+
+  router.get('/search-user-status/', validator.statusList, ApiV3FormValidator, async(req, res) => {
+
+    const page = parseInt(req.query.page) || 1;
+    const { statusList } = req.body;
+
+    const statusNoList = statusList.map(element => statusNo[element]);
+
+    try {
+      const paginateResult = await User.paginate(
+        { status: { $in: statusNoList } },
+        {
+          sort: { status: 1, username: 1, createdAt: 1 },
+          page,
+          limit: PAGE_ITEMS,
+        },
+      );
+      return res.apiv3({ paginateResult });
+    }
+    catch (err) {
+      const msg = 'Error occurred in fetching user group list';
+      logger.error('Error', err);
+      return res.apiv3Err(new ErrorV3(msg, 'user-group-list-fetch-failed'), 500);
+    }
+  });
+
   validator.inviteEmail = [
     // isEmail prevents line breaks, so use isString
     body('shapedEmailList').custom((value) => {
@@ -424,50 +468,6 @@ module.exports = (crowi) => {
     }
   });
 
-  const statusNo = {
-    registered: User.STATUS_REGISTERED,
-    active: User.STATUS_ACTIVE,
-    suspended: User.STATUS_SUSPENDED,
-    invited: User.STATUS_INVITED,
-  };
-
-  validator.statusList = [
-    body('statusList').custom((value) => {
-      const error = [];
-      value.forEach((status) => {
-        if (!Object.keys(statusNo)) {
-          error.push(status);
-        }
-      });
-      return (error.length === 0);
-    }),
-  ];
-
-  router.get('/selected-status-users/', validator.statusList, ApiV3FormValidator, async(req, res) => {
-
-    const page = parseInt(req.query.page) || 1;
-    const { statusList } = req.body;
-
-    const statusNoList = statusList.map(element => statusNo[element]);
-
-    try {
-      const paginateResult = await User.paginate(
-        { status: { $in: statusNoList } },
-        {
-          sort: { status: 1, username: 1, createdAt: 1 },
-          page,
-          limit: PAGE_ITEMS,
-        },
-      );
-      return res.apiv3({ paginateResult });
-    }
-    catch (err) {
-      const msg = 'Error occurred in fetching user group list';
-      logger.error('Error', err);
-      return res.apiv3Err(new ErrorV3(msg, 'user-group-list-fetch-failed'), 500);
-    }
-  });
-
   /**
    * @swagger
    *