lrf402788946 4 年 前
コミット
b5d4ab2a3a
4 ファイル変更20 行追加2 行削除
  1. 4 0
      app/controller/.groupscore.js
  2. 6 0
      app/router.js
  3. 10 0
      app/service/groupscore.js
  4. 0 2
      app/service/personalscore.js

+ 4 - 0
app/controller/.groupscore.js

@@ -34,4 +34,8 @@ module.exports = {
       count: true,
     },
   },
+  opera: {
+    requestBody: ["data"],
+    service: "opera",
+  },
 };

+ 6 - 0
app/router.js

@@ -599,4 +599,10 @@ module.exports = app => {
     '/api/train/groupscore/update/:id',
     controller.groupscore.update
   );
+  // 组上分(混合操作,有添加,也有修改)
+  router.post(
+    'groupscore',
+    '/api/train/groupscore/opera',
+    controller.groupscore.opera
+  );
 };

+ 10 - 0
app/service/groupscore.js

@@ -11,6 +11,16 @@ class GroupscoreService extends CrudService {
     super(ctx, 'groupscore');
     this.model = this.ctx.model.Groupscore;
   }
+  async opera({ data }) {
+    const cList = data.filter(f => !(f.id || f._id));
+    const uList = data.filter(f => f.id || f._id);
+    for (const i of cList) {
+      await this.model.create(i);
+    }
+    for (const i of uList) {
+      await this.model.findByIdAndUpdate(i.id || i._id, i);
+    }
+  }
 }
 
 module.exports = GroupscoreService;

+ 0 - 2
app/service/personalscore.js

@@ -15,8 +15,6 @@ class PersonalscoreService extends CrudService {
   async opera({ data }) {
     const cList = data.filter(f => !(f.id || f._id));
     const uList = data.filter(f => f.id || f._id);
-    console.log(cList);
-    console.log(uList);
     for (const i of cList) {
       await this.model.create(i);
     }