lrf402788946 %!s(int64=4) %!d(string=hai) anos
pai
achega
6c9b57771a
Modificáronse 1 ficheiros con 4 adicións e 2 borrados
  1. 4 2
      app/service/score.js

+ 4 - 2
app/service/score.js

@@ -15,10 +15,11 @@ class ScoreService extends CrudService {
   }
 
   async create(data) {
-    const { lessonid, stuid, teacherid, score } = data;
+    const { lessonid, stuid, teacherid, score, remark } = data;
     let res = await this.model.findOne({ stuid, lessonid, teacherid });
     if (res) {
       if (score) res.score = score;
+      if (remark)res.remark = remark;
       res = await res.save();
     } else {
       res = await this.model.create(data);
@@ -29,11 +30,12 @@ class ScoreService extends CrudService {
   }
 
 
-  async update({ id, score }) {
+  async update({ id, score, remark }) {
     const r = await this.model.findById(id);
     if (r) {
       // 修改分数,重置状态,下面重新计算
       r.score = score;
+      r.remark = remark;
       await r.save();
     }
     this.computedScore({ teacherid: r.teacherid });