liuyu 5 年之前
父节点
当前提交
a7052b71c8
共有 1 个文件被更改,包括 31 次插入38 次删除
  1. 31 38
      app/service/tasks.js

+ 31 - 38
app/service/tasks.js

@@ -16,46 +16,39 @@ class TasksService extends CrudService {
     const mqid = uuid();
     const newdata = { ...requestBody, mqid };
     const result = await this.model.create(newdata);
-    const pathStu = this.ctx.app.config.baseUrl + '/enrollments/dataimp?type=' + requestBody.type + '&content=' + requestBody.content;
-    const res = await this.ctx.curl(pathStu, {
-      method: 'GET',
-      dataType: 'json',
-    });
-    if (res) {
-      const task = await this.model.findById(result.id);
-      if (res.data.data.errcount === 0) {
-        task.status = '1';
-      } else {
-        task.status = '2';
-        task.errmsg = res.data.data.errmsg;
-      }
-      task.save();
-    }
+    // const pathStu = this.ctx.app.config.baseUrl + '/enrollments/dataimp?type=' + requestBody.type + '&content=' + requestBody.content;
+    // const res = await this.ctx.curl(pathStu, {
+    //   method: 'GET',
+    //   dataType: 'json',
+    // });
+    // if (res) {
+    //   const task = await this.model.findById(result.id);
+    //   if (res.data.data.errcount === 0) {
+    //     task.status = '1';
+    //   } else {
+    //     task.status = '2';
+    //     task.errmsg = res.data.data.errmsg;
+    //   }
+    //   task.save();
+    // }
     // const result = await this.ctx.model.Tasks.create(newdata);
+    // TODO mq暂时不用,解决后使用mq导入数据
     if (result) {
-      // const pathStu = this.ctx.app.config.baseUrl + 'stud/enrollments/dataimp';
-      // const data = { type: newdata.type, content: newdata.content };
-      // const res = await this.ctx.curl(pathStu, {
-      //   method: 'GET',
-      //   dataType: 'json',
-      //   data: JSON.stringify(data),
-      // });
-      // TODO mq暂时不用,解决后使用mq导入数据
-      // const { mq } = this.ctx;
-      // if (mq) {
-      //   const msg = requestBody.name + '上传文件' + requestBody.content;
-      //   const parm = {
-      //     durable: true,
-      //     headers: {
-      //       userid: requestBody.userid,
-      //       mqid,
-      //     } };
-      //   console.log(parm);
-      //   console.log(msg);
-      //   await mq.topic('stu_import', requestBody.userid, msg, parm);
-      // } else {
-      //   this.ctx.logger.error('!!!!!!没有配置MQ插件!!!!!!');
-      // }
+      const { mq } = this.ctx;
+      if (mq) {
+        const msg = requestBody.name + '上传文件' + requestBody.content;
+        const parm = {
+          durable: true,
+          headers: {
+            userid: requestBody.userid,
+            mqid,
+          } };
+        console.log(parm);
+        console.log(msg);
+        await mq.topic('stu_import', requestBody.userid, msg, parm);
+      } else {
+        this.ctx.logger.error('!!!!!!没有配置MQ插件!!!!!!');
+      }
     }
   }
 }