lrf402788946 %!s(int64=5) %!d(string=hai) anos
pai
achega
9d6c4f4178
Modificáronse 3 ficheiros con 38 adicións e 9 borrados
  1. 2 2
      app/controller/.dock.js
  2. 21 6
      app/router.js
  3. 15 1
      app/service/dock.js

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

@@ -49,7 +49,7 @@ module.exports = {
   },
   dockCheck: {
     params: ["!id"],
-    requestBody: ["is_allowed", "reason", "user_id"],
-    service: "check",
+    requestBody: ["is_allowed", "reason"],
+    service: "dockCheck",
   },
 };

+ 21 - 6
app/router.js

@@ -12,9 +12,16 @@ module.exports = app => {
   router.post('present', '/api/live/present/:id', controller.present.update);
 
   // 礼物表设置路由
-  router.resources('presentrcord', '/api/live/presentrcord', controller.presentrcord); // index、create、show、destroy
-  router.post('presentrcord', '/api/live/presentrcord/:id', controller.presentrcord.update);
-
+  router.resources(
+    'presentrcord',
+    '/api/live/presentrcord',
+    controller.presentrcord
+  ); // index、create、show、destroy
+  router.post(
+    'presentrcord',
+    '/api/live/presentrcord/:id',
+    controller.presentrcord.update
+  );
 
   // 房间表设置路由
   router.resources('room', '/api/live/room', controller.room); // index、create、show、destroy
@@ -24,7 +31,6 @@ module.exports = app => {
   router.resources('roomchat', '/api/live/roomchat', controller.roomchat); // index、create、show、destroy
   router.post('roomchat', '/api/live/roomchat/:id', controller.roomchat.update);
 
-
   // 公共聊天设置路由
   router.resources('chat', '/api/live/chat', controller.chat); // index、create、show、destroy
   router.post('chat', '/api/live/chat/:id', controller.chat.update);
@@ -32,13 +38,22 @@ module.exports = app => {
   // 对接会表设置路由
   router.resources('dock', '/api/live/dock', controller.dock); // index、create、show、destroy
   router.post('dock', '/api/live/dock/:id', controller.dock.update);
+  router.post('dock', '/api/live/dock/check/:id', controller.dock.dockCheck);
   // 对接会申请表
   router.post('dock', '/api/live/dock/apply/:id', controller.dock.apply);
-  router.post('dock', '/api/live/dock/apply/:dock_id/check/:id', controller.dock.check);
+  router.post(
+    'dock',
+    '/api/live/dock/apply/:dock_id/check/:id',
+    controller.dock.check
+  );
 
   // 栏目表设置路由
   router.resources('column', '/api/live/column', controller.column); // index、create、show、destroy
-  router.post('column', '/api/live/column/update/:id', controller.column.update);
+  router.post(
+    'column',
+    '/api/live/column/update/:id',
+    controller.column.update
+  );
 
   // 信息表设置路由
   router.resources('news', '/api/live/news', controller.news); // index、create、show、destroy

+ 15 - 1
app/service/dock.js

@@ -28,7 +28,10 @@ class ChatService extends CrudService {
     if (!dock) {
       throw new BusinessError('没有查询到该对接会');
     }
-    dock.apply.push({ ...body, apply_time: moment().format('YYYY-MM-DD HH:mm:ss') });
+    dock.apply.push({
+      ...body,
+      apply_time: moment().format('YYYY-MM-DD HH:mm:ss'),
+    });
     const res = await dock.save();
     const info = _.last(res.apply);
     return info;
@@ -48,6 +51,17 @@ class ChatService extends CrudService {
     const res = dock.save();
     return res;
   }
+  async dockCheck({ id }, { is_allowed, reason = '' }) {
+    const res = this.model.findOne(id);
+    if (!res) {
+      throw new BusinessError('没有查询到该对接会');
+    }
+    assert(is_allowed, '请选择审核结果');
+    res.is_allowed = is_allowed;
+    res.reason = reason;
+    const ret = res.save();
+    return ret;
+  }
 }
 
 module.exports = ChatService;