lrf402788946 4 éve
szülő
commit
89f3a56800
3 módosított fájl, 9 hozzáadás és 5 törlés
  1. 4 2
      app/controller/.chatroom.js
  2. 2 0
      app/model/chatroom.js
  3. 3 3
      app/service/attendance.js

+ 4 - 2
app/controller/.chatroom.js

@@ -1,6 +1,6 @@
 module.exports = {
   create: {
-    requestBody: ["!teacherid", "!studentid"],
+    requestBody: ["!teacherid", "teacher", "!studentid", "student"],
   },
   destroy: {
     params: ["!id"],
@@ -8,7 +8,7 @@ module.exports = {
   },
   update: {
     params: ["!id"],
-    requestBody: ["number", "!teacherid", "!studentid"],
+    requestBody: ["!teacherid", "teacher", "!studentid", "student"],
   },
   show: {
     parameters: {
@@ -22,6 +22,8 @@ module.exports = {
         number: "number",
         teacherid: "teacherid",
         studentid: "studentid",
+        teacher: "teacher",
+        student: "student"
       },
     },
     service: "query",

+ 2 - 0
app/model/chatroom.js

@@ -6,7 +6,9 @@ const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
 const ChatroommSchema = {
   number: { type: String, required: false, maxLength: 200, default: new Date().getTime() }, // 房间号
   teacherid: { type: String, required: true, maxLength: 200 }, // 教师id
+  teacher: { type: String, required: true, maxLength: 200 }, // 教师
   studentid: { type: String, required: true, maxLength: 200 }, // 学生id
+  student: { type: String, required: true, maxLength: 200 }, // 学生
 };
 
 

+ 3 - 3
app/service/attendance.js

@@ -22,10 +22,10 @@ class AttendanceService extends CrudService {
   }
 
   async attendancecreate(data) {
-    const { unionid, type, ibeacon } = data;
-    assert(unionid && type && ibeacon, '缺少信息项');
+    const { openid, type, ibeacon } = data;
+    assert(openid && type && ibeacon, '缺少信息项');
     // 通过openid取得学生信息
-    const user = await this.ctx.service.user.findByunionid(unionid);
+    const user = await this.ctx.service.user.findByappopenid(openid);
     if (!user) {
       throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '用户不存在');
     }