lrf 2 rokov pred
rodič
commit
2e4dc2da03
1 zmenil súbory, kde vykonal 8 pridanie a 3 odobranie
  1. 8 3
      app/service/teamApply.js

+ 8 - 3
app/service/teamApply.js

@@ -29,11 +29,16 @@ class TeamApplyService extends CrudService {
     });
     if (list.length > 0) {
       list = JSON.parse(JSON.stringify(list));
-      list = list.map(i => {
+      const arr = [];
+      for (const i of list) {
+        const { user_id } = i;
+        const num = await this.model.count({ $or: [{ one_member_id: user_id }, { two_member_id: user_id }] });
+        if (num > 0) continue;
         i.user_name = _.get(i, 'user_id.user_id.name');
         i.user_id = _.get(i, 'user_id._id');
-        return i;
-      });
+        arr.push(i);
+      }
+      list = arr;
     }
 
     return list;