ruifeng_liu 3 年之前
父节点
当前提交
400d44221e
共有 1 个文件被更改,包括 13 次插入1 次删除
  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;