ruifeng_liu 3 năm trước cách đây
mục cha
commit
400d44221e
1 tập tin đã thay đổi với 13 bổ sung1 xóa
  1. 13 1
      app/service/util.js

+ 13 - 1
app/service/util.js

@@ -87,7 +87,19 @@ class UtilService extends CrudService {
   }
   async utilMethod(query, body) {
     // // 重置班级
-    console.log('in function:');
+    // 找到要删除的学生
+    const res = await this.ctx.model.Student.find({ school_name: '吉林职业技术学院', planid: '60769b703cead37068645fb2', termid: { $ne: '60779c0b2ec7ac704ce301ab' } });
+    // const test = res.map(f => {
+    //   return { name: f.name, openid: f.openid, id: f._id };
+    // });
+    const ids = res.map(i => i._id);
+    await this.ctx.model.User.deleteMany({ uid: ids });
+    await this.ctx.model.Student.deleteMany({ school_name: '吉林职业技术学院', planid: '60769b703cead37068645fb2', termid: { $ne: '60779c0b2ec7ac704ce301ab' } });
+    // const ids = res.map(i => i.openid);
+    // // console.log(ids);
+    //
+    // console.log(userRes.length);
+
     // const { planid, termid, batchid, classid } = query;
     // const filters = {};
     // if (classid) filters.classid = classid;