lrf402788946 %!s(int64=4) %!d(string=hai) anos
pai
achega
6a8180cc84
Modificáronse 1 ficheiros con 17 adicións e 17 borrados
  1. 17 17
      app/service/notice.js

+ 17 - 17
app/service/notice.js

@@ -132,23 +132,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 });
-  //   }
-  //   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;