liuyu 4 سال پیش
والد
کامیت
c51a5a0b68
5فایلهای تغییر یافته به همراه30 افزوده شده و 4 حذف شده
  1. 2 2
      app/controller/.room.js
  2. 5 0
      app/controller/room.js
  3. 2 1
      app/model/room.js
  4. 1 1
      app/router.js
  5. 20 0
      app/service/room.js

+ 2 - 2
app/controller/.room.js

@@ -1,6 +1,6 @@
 module.exports = {
   create: {
-    requestBody: ["title","name", "type", "filedir", "url", "anchorid","username","status","content","starttime","endtime","adverts","isadvert","stream_id","ishis","file_id","queid","isque","otheid","shmaiid","zjr"],
+    requestBody: ["title","name", "type", "filedir", "url", "anchorid","username","status","content","starttime","endtime","adverts","isadvert","stream_id","ishis","file_id","queid","isque","otheid","shmaiid","zjr","swichzjr"],
   },
   destroy: {
     params: ["!id"],
@@ -8,7 +8,7 @@ module.exports = {
   },
   update: {
     params: ["!id"],
-    requestBody: ["title","name", "type", "filedir", "url", "anchorid","username","status","content","starttime","endtime","adverts","isadvert","stream_id","ishis","file_id","queid","isque","otheid","shmaiid","zjr"],
+    requestBody: ["title","name", "type", "filedir", "url", "anchorid","username","status","content","starttime","endtime","adverts","isadvert","stream_id","ishis","file_id","queid","isque","otheid","shmaiid","zjr","swichzjr"],
   },
   show: {
     parameters: {

+ 5 - 0
app/controller/room.js

@@ -173,6 +173,11 @@ class RoomController extends Controller {
     this.ctx.ok({ data });
   }
 
+  async switchzjr() {
+    const data = await this.service.switchzjr(this.ctx.request.body);
+    this.ctx.ok({ data });
+  }
+
 }
 
 module.exports = CrudController(RoomController, meta);

+ 2 - 1
app/model/room.js

@@ -31,7 +31,8 @@ const RoomSchema = {
   adverts: { type: [ AdvertInfo ], required: false, select: true }, // 广告位
   queid: { type: String, required: false, maxLength: 200 }, // 问卷id
   isque: { type: String, required: false, maxLength: 64, default: '0' }, // 状态0、无1、有
-  zjr: { type: Array, required: false, select: true }, // 主讲人
+  zjr: { type: Array, required: false, select: true }, // 主讲人列表
+  swichzjr: { type: String, required: false }, // 选择主讲人
 };
 
 const schema = new Schema(RoomSchema, { toJSON: { virtuals: true } });

+ 1 - 1
app/router.js

@@ -30,7 +30,7 @@ module.exports = app => {
   router.post('/api/onlive/room/roomquestclose', controller.room.roomquestclose);
   router.post('/api/onlive/room/updateanchor', controller.room.updateanchor);
   router.post('/api/onlive/room/updateshmai', controller.room.updateshmai);
-
+  router.post('/api/onlive/room/switchzjr', controller.room.switchzjr);
 
   // 聊天表设置路由
   router.resources('chat', '/api/onlive/chat', controller.chat); // index、create、show、destroy

+ 20 - 0
app/service/room.js

@@ -156,6 +156,26 @@ class RoomService extends CrudService {
     return res;
   }
 
+  async switchzjr({ id, switchzjr }) {
+    const res = await this.model.findById(id);
+    if (res) {
+      res.switchzjr = switchzjr;
+      const result = await res.save();
+      if (result) {
+        const { mq } = this.ctx;
+        if (mq) {
+          const exchange = 'switch_zjr_' + id;
+          const parm = {
+            durable: true,
+            headers: {
+              userid: res.id,
+            } };
+          await mq.fanout(exchange, res.id, JSON.stringify(res), parm);
+        }
+      }
+    }
+    return res;
+  }
 }
 
 module.exports = RoomService;