reloaded 5 anos atrás
pai
commit
77d60e38c7
3 arquivos alterados com 61 adições e 45 exclusões
  1. 46 43
      app/controller/.leave.js
  2. 2 1
      app/model/leave.js
  3. 13 1
      app/service/leave.js

+ 46 - 43
app/controller/.leave.js

@@ -1,64 +1,67 @@
 module.exports = {
   create: {
     requestBody: [
-      'batchid',
-      'termid',
-      'planid',
-      '!studentid',
-      'starttime',
-      'endtime',
-      'reason',
-      'status',
-      'refcause',
-      'type'
-    ]
+      "batchid",
+      "termid",
+      "planid",
+      "!studentid",
+      "classid",
+      "starttime",
+      "endtime",
+      "reason",
+      "status",
+      "refcause",
+      "type",
+    ],
   },
   destroy: {
-    params: ['!id'],
-    service: 'delete'
+    params: ["!id"],
+    service: "delete",
   },
   update: {
-    params: ['!id'],
+    params: ["!id"],
     requestBody: [
-      'batchid',
-      'termid',
-      'planid',
-      'studentid',
-      'starttime',
-      'endtime',
-      'reason',
-      'status',
-      'refcause',
-      'type'
-    ]
+      "batchid",
+      "termid",
+      "planid",
+      "classid",
+      "studentid",
+      "starttime",
+      "endtime",
+      "reason",
+      "status",
+      "refcause",
+      "type",
+    ],
   },
   show: {
     parameters: {
-      params: ['!id']
+      params: ["!id"],
     },
-    service: 'fetch'
+    service: "fetch",
   },
   index: {
     parameters: {
       query: {
-        batchid:'batchid',
-        termid: 'termid',
-        planid: 'planid',
-        studentid :'studentid',
-        starttime :'starttime',
-        endtime :'endtime',
-        reason :'reason',
-        status :'status',
-        refcause :'refcause',
-        type:'type'
-      }
+        batchid: "batchid",
+        termid: "termid",
+        planid: "planid",
+        studentid: "studentid",
+        classid: "classid",
+        starttime: "starttime",
+        endtime: "endtime",
+        reason: "reason",
+        status: "status",
+        refcause: "refcause",
+        type: "type",
+      },
     },
-    service: 'query',
+    service: "query",
     options: {
-      query: ['skip', 'limit'],
-      sort: ['meta.createdAt'],
+      query: ["skip", "limit"],
+      sort: ["meta.createdAt"],
       desc: true,
-      count: true
-    }
+      count: true,
+    },
   },
 };

+ 2 - 1
app/model/leave.js

@@ -6,12 +6,13 @@ const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
 const LeaveSchema = {
   batchid: { type: String, required: false, maxLength: 200 }, // 批次
   termid: { type: String, required: false, maxLength: 200 }, // 期
+  classid: { type: String, required: false, maxLength: 200 }, // 班级id
   planid: { type: String, required: false, maxLength: 200 }, // 计划
   studentid: { type: String, required: true, maxLength: 200 }, // 学生id
   starttime: { type: String, required: false, maxLength: 200 }, // 开始时间
   endtime: { type: String, required: false, maxLength: 500 }, // 结束时间
   reason: { type: String, required: false, maxLength: 2000 }, // 请假理由
-  status: { type: String, required: false, maxLength: 200, default: '0' }, // 状态,0-审核中,1-通过,2-未通过
+  status: { type: String, required: false, maxLength: 200, default: "0" }, // 状态,0-审核中,1-通过,2-未通过
   refcause: { type: String, required: false, maxLength: 2000 }, // 拒绝原因
   type: { type: String, required: false, maxLength: 200 }, // 类型,0-请假,1-退出
 };

+ 13 - 1
app/service/leave.js

@@ -34,7 +34,7 @@ class LeaveService extends CrudService {
 
   async update({ id }, data) {
     const leave = await this.model.findById(id);
-    const { studentid, starttime, endtime, reason, status, refcause } = data;
+    const { studentid, starttime, endtime, reason, status, refcause, batchid, termid, classid, planid } = data;
     if (studentid) {
       leave.studentid = studentid;
     }
@@ -47,6 +47,18 @@ class LeaveService extends CrudService {
     if (reason) {
       leave.reason = reason;
     }
+    if (batchid) {
+      leave.batchid = batchid;
+    }
+    if (termid) {
+      leave.termid = termid;
+    }
+    if (classid) {
+      leave.classid = classid;
+    }
+    if (planid) {
+      leave.planid = planid;
+    }
     if (status) {
       leave.status = status;
       const student = await this.smodel.findById(leave.studentid);