liuyu 4 anos atrás
pai
commit
428da7ae3f
5 arquivos alterados com 30 adições e 2 exclusões
  1. 2 2
      app/controller/.room.js
  2. 5 0
      app/controller/room.js
  3. 1 0
      app/model/room.js
  4. 1 0
      app/router.js
  5. 21 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"],
+    requestBody: ["title","name", "type", "filedir", "url", "anchorid","username","status","content","starttime","endtime","adverts","isadvert","stream_id","ishis","file_id","queid","isque","otheid"],
   },
   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"],
+    requestBody: ["title","name", "type", "filedir", "url", "anchorid","username","status","content","starttime","endtime","adverts","isadvert","stream_id","ishis","file_id","queid","isque","otheid"],
   },
   show: {
     parameters: {

+ 5 - 0
app/controller/room.js

@@ -158,6 +158,11 @@ class RoomController extends Controller {
     this.ctx.ok({ data });
   }
 
+  async updateanchor() {
+    const data = await this.service.updateanchor(this.ctx.request.body);
+    this.ctx.ok({ data });
+  }
+
   async roomquestclose() {
     const data = await this.service.roomquestclose(this.ctx.request.body);
     this.ctx.ok({ data });

+ 1 - 0
app/model/room.js

@@ -21,6 +21,7 @@ const RoomSchema = {
   file_id: { type: String, required: false }, // 文件id
   content: { type: String, required: false }, // 直播简介
   anchorid: { type: String, required: false, maxLength: 200 }, // 主播id
+  otheid: { type: String, required: false, maxLength: 200 }, // 主讲id
   username: { type: String, required: false, maxLength: 200 }, // 主播名称
   starttime: { type: String, required: false }, // 开始时间
   endtime: { type: String, required: false }, // 结束时间

+ 1 - 0
app/router.js

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

+ 21 - 0
app/service/room.js

@@ -81,6 +81,27 @@ class RoomService extends CrudService {
     return res;
   }
 
+  async updateanchor(id, otheid) {
+    const res = await this.model.findById(id);
+    if (res) {
+      res.otheid = otheid;
+      const result = await res.save();
+      if (result) {
+        const { mq } = this.ctx;
+        if (mq) {
+          const exchange = 'othe_publish_' + result.id;
+          const parm = {
+            durable: true,
+            headers: {
+              userid: result.id,
+            } };
+          await mq.fanout(exchange, result.id, JSON.stringify(result), parm);
+        }
+      }
+    }
+    return res;
+  }
+
   async roomquest(data) {
     const res = await this.model.findById(data.roomid);
     if (!res) {