lrf402788946 4 years ago
parent
commit
f3e2a4ce15
3 changed files with 12 additions and 10 deletions
  1. 0 1
      app/controller/dock/.transaction.js
  2. 7 4
      app/service/dock/transaction.js
  3. 5 5
      config/config.default.js

+ 0 - 1
app/controller/dock/.transaction.js

@@ -62,7 +62,6 @@ module.exports = {
       query: ["skip", "limit"],
       sort: ["meta.createdAt"],
       desc: true,
-      count: true,
     },
   },
   step: {

+ 7 - 4
app/service/dock/transaction.js

@@ -16,17 +16,20 @@ class TransactionService extends CrudService {
     query = this.ctx.service.util.util.dealQuery(query);
     const { user_id, supplier, demander, status, ...info } = query;
     if (status)query.status = status.split(',');
-    let res;
+    let data;
+    let total;
     if (!user_id) {
-      res = await this.model.find(query).skip(parseInt(skip)).limit(parseInt(limit))
+      data = await this.model.find(query).skip(parseInt(skip)).limit(parseInt(limit))
         .sort({ 'meta.createdAt': -1 });
+      total = await this.model.count(query);
     } else {
       const nquery = { ...info, $or: [{ supplier: user_id }, { demander: user_id }] };
       if (query.status) nquery.status = query.status;
-      res = await this.model.find(nquery).skip(parseInt(skip)).limit(parseInt(limit))
+      data = await this.model.find(nquery).skip(parseInt(skip)).limit(parseInt(limit))
         .sort({ 'meta.createdAt': -1 });
+      total = await this.model.count(nquery);
     }
-    return res;
+    return { data, total };
   }
 
   /**

+ 5 - 5
config/config.default.js

@@ -39,11 +39,11 @@ module.exports = appInfo => {
   config.mongoose = {
     url: `mongodb://localhost:27017/${config.dbName}`,
     options: {
-      user: 'admin',
-      pass: '111111',
-      authSource: 'admin',
-      useNewUrlParser: true,
-      useCreateIndex: true,
+      // user: 'admin',
+      // pass: '111111',
+      // authSource: 'admin',
+      // useNewUrlParser: true,
+      // useCreateIndex: true,
     },
   };