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