guhongwei 2 years ago
parent
commit
be3f37c4d5
1 changed files with 4 additions and 19 deletions
  1. 4 19
      app/service/notice.js

+ 4 - 19
app/service/notice.js

@@ -16,10 +16,7 @@ class NoticeService extends CrudService {
   async query({ user_id, ...query }, { skip = 0, limit = 0 } = {}) {
   async query({ user_id, ...query }, { skip = 0, limit = 0 } = {}) {
     const condition = { ...query };
     const condition = { ...query };
     if (user_id) condition.receive_user = { $elemMatch: { user_id } };
     if (user_id) condition.receive_user = { $elemMatch: { user_id } };
-    const data = await this.model
-      .find(condition)
-      .skip(parseInt(skip))
-      .limit(parseInt(limit));
+    const data = await this.model.find(condition).skip(parseInt(skip)).limit(parseInt(limit));
     if (!data) throw new BusinessError(ErrorCode.DATA_NOT_EXIST);
     if (!data) throw new BusinessError(ErrorCode.DATA_NOT_EXIST);
     return data;
     return data;
   }
   }
@@ -30,29 +27,17 @@ class NoticeService extends CrudService {
     if (type !== '3') {
     if (type !== '3') {
       if (type === '0') {
       if (type === '0') {
         for (const val of userList) {
         for (const val of userList) {
-          body.receive_user.push({
-            user_id: val._id,
-            user_name: val.nickname,
-            status: '0',
-          });
+          body.receive_user.push({ user_id: val._id, user_name: val.nickname, status: '0' });
         }
         }
       } else if (type === '1') {
       } else if (type === '1') {
         userList = userList.filter(i => i.type === '1');
         userList = userList.filter(i => i.type === '1');
         for (const val of userList) {
         for (const val of userList) {
-          body.receive_user.push({
-            user_id: val._id,
-            user_name: val.nickname,
-            status: '0',
-          });
+          body.receive_user.push({ user_id: val._id, user_name: val.nickname, status: '0' });
         }
         }
       } else if (type === '2') {
       } else if (type === '2') {
         userList = userList.filter(i => i.type === '2');
         userList = userList.filter(i => i.type === '2');
         for (const val of userList) {
         for (const val of userList) {
-          body.receive_user.push({
-            user_id: val._id,
-            user_name: val.nickname,
-            status: '0',
-          });
+          body.receive_user.push({ user_id: val._id, user_name: val.nickname, status: '0' });
         }
         }
       }
       }
     }
     }