|
@@ -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;
|