asd123a20 3 years ago
parent
commit
1c3612e275
3 changed files with 4 additions and 5 deletions
  1. 1 1
      app/model/Column.js
  2. 1 2
      app/service/column.js
  3. 2 2
      app/service/content.js

+ 1 - 1
app/model/Column.js

@@ -13,7 +13,7 @@ module.exports = app => {
       type: String,
     },
     menuList: {
-      type: Array,
+      type: String,
     },
     createAt: {
       type: String,

+ 1 - 2
app/service/column.js

@@ -87,7 +87,7 @@ class ColumnService extends Service {
     if (code) filter.code = code;
     try {
       let res;
-      const total = await model.find();
+      const total = await model.find({ ...filter });
       if (skip && limit) {
         res = await model.find({ ...filter }).skip(Number(skip) * Number(limit)).limit(Number(limit));
       } else {
@@ -95,7 +95,6 @@ class ColumnService extends Service {
       }
       return { errmsg: '', errcode: 0, data: res, total: total.length };
     } catch (error) {
-      console.log(error, 111);
       throw new Error({ errcode: -2001, errmsg: '查询失败' });
     }
   }

+ 2 - 2
app/service/content.js

@@ -51,8 +51,8 @@ class ContentService extends Service {
       const res = await model.findById(id);
       const token = Boolean(this.ctx.request.header.authorization);
       if (!token) {
-        const hits = res.hits++;
-        await model.findById(id).update({ hits });
+        res.hits++;
+        await model.findById(id).update(res);
       }
       return { errmsg: '', errcode: 0, data: res };
     } catch (error) {