lrf402788946 4 år sedan
förälder
incheckning
b1ede97f6f
2 ändrade filer med 21 tillägg och 21 borttagningar
  1. 4 4
      app/controller/notice.js
  2. 17 17
      app/service/notice.js

+ 4 - 4
app/controller/notice.js

@@ -17,10 +17,10 @@ class NoticeController extends Controller {
     this.ctx.ok({ data: res });
   }
 
-  async index() {
-    const data = await this.service.query(this.ctx.query);
-    this.ctx.ok({ ...data });
-  }
+  // async index() {
+  //   const data = await this.service.query(this.ctx.query);
+  //   this.ctx.ok({ ...data });
+  // }
 }
 
 module.exports = CrudController(NoticeController, meta);

+ 17 - 17
app/service/notice.js

@@ -133,23 +133,23 @@ class NoticeService extends CrudService {
     }
   }
 
-  async query({ skip, limit, ...info }) {
-    const total = await this.model.count(info);
-    const notices = await this.model.find(info).skip(Number(skip)).limit(Number(limit));
-    const res = [];
-    for (const _notice of notices) {
-      const notice = _.cloneDeep(JSON.parse(JSON.stringify(_notice)));
-      const { noticeid, content, notified, meta, _id } = notice;
-      const elm = [];
-      for (const notified of notice.notified) {
-        const _notified = _.cloneDeep(JSON.parse(JSON.stringify(notified)));
-        const userinfo = await this.findUserInfo(_notified.notifiedid);
-        elm.push({ ...JSON.parse(JSON.stringify(userinfo)), ..._notified });
-      }
-      res.push({ noticeid, content, meta, notified: elm, _id });
-    }
-    return { data: res, total };
-  }
+  // async query({ skip, limit, ...info }) {
+  //   const total = await this.model.count(info);
+  //   const notices = await this.model.find(info).skip(Number(skip)).limit(Number(limit));
+  //   const res = [];
+  //   for (const _notice of notices) {
+  //     const notice = _.cloneDeep(JSON.parse(JSON.stringify(_notice)));
+  //     const { noticeid, content, notified, meta, _id } = notice;
+  //     const elm = [];
+  //     for (const notified of notice.notified) {
+  //       const _notified = _.cloneDeep(JSON.parse(JSON.stringify(notified)));
+  //       const userinfo = await this.findUserInfo(_notified.notifiedid);
+  //       elm.push({ ...JSON.parse(JSON.stringify(userinfo)), ..._notified });
+  //     }
+  //     res.push({ noticeid, content, meta, notified: elm, _id });
+  //   }
+  //   return { data: res, total };
+  // }
 
   async findUserInfo(userid) {
     let userinfo;