liuyu hace 4 años
padre
commit
8f2690ee1e
Se han modificado 1 ficheros con 6 adiciones y 0 borrados
  1. 6 0
      app/service/room.js

+ 6 - 0
app/service/room.js

@@ -11,6 +11,7 @@ class RoomService extends CrudService {
   constructor(ctx) {
     super(ctx, 'room');
     this.model = this.ctx.model.Room;
+    this.rumodel = this.ctx.model.Roomuser;
   }
 
   async create(data) {
@@ -19,6 +20,11 @@ class RoomService extends CrudService {
     if (room_) {
       throw new BusinessError('此房间已经存在,请重新输入');
     }
+    const roomuser = await this.rumodel.findById(data.anchorid);
+    if (!roomuser) {
+      throw new BusinessError(ErrorCode.DATA_NOT_EXIST);
+    }
+    data.username = roomuser.name;
     const res = await this.model.create(data);
     return res;
   }