lrf402788946 4 年之前
父节点
当前提交
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;