lrf402788946 4 лет назад
Родитель
Сommit
57adff12e4
1 измененных файлов с 10 добавлено и 0 удалено
  1. 10 0
      app/service/chatroom.js

+ 10 - 0
app/service/chatroom.js

@@ -13,6 +13,16 @@ class ChatroomService extends CrudService {
     this.model = this.ctx.model.Chatroom;
   }
 
+  async create({ teacherid, teacher, studentid, student }) {
+    assert(teacherid, '缺少教师id');
+    assert(teacher, '缺少教师姓名');
+    assert(studentid, '缺少学生id');
+    assert(student, '缺少学生姓名');
+    const res = await this.model.find({ teacherid, teacher, studentid, student });
+    if (res) return res;
+    const cres = await this.model.create({ teacherid, teacher, studentid, student });
+    return cres;
+  }
 }
 
 module.exports = ChatroomService;