ソースを参照

增加查询我的申请对接会接口

liuyu 4 年 前
コミット
4549d89416
3 ファイル変更16 行追加0 行削除
  1. 7 0
      app/controller/dock.js
  2. 1 0
      app/router.js
  3. 8 0
      app/service/dock.js

+ 7 - 0
app/controller/dock.js

@@ -11,6 +11,13 @@ class DockController extends Controller {
     super(ctx);
     this.service = this.ctx.service.dock;
   }
+
+  // GET
+  // 查询
+  async myapply() {
+    const res = await this.service.myapply(this.ctx.query);
+    this.ctx.ok({ ...res });
+  }
 }
 
 module.exports = CrudController(DockController, meta);

+ 1 - 0
app/router.js

@@ -36,6 +36,7 @@ module.exports = app => {
   router.post('chat', '/api/live/chat/:id', controller.chat.update);
 
   // 对接会表设置路由
+  router.get('/api/live/dock/myapply', controller.dock.myapply); // 查询申请的对接列表
   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);

+ 8 - 0
app/service/dock.js

@@ -62,6 +62,14 @@ class ChatService extends CrudService {
     const res = await dock.save();
     return res;
   }
+
+  // 根据申请人id查询所有申请的对接会
+  async myapply({ user_id, status, skip, limit }) {
+    const total = await this.model.count({ status, 'apply.user_id': user_id });
+    const data = await this.model.find({ status, 'apply.user_id': user_id }).skip(Number(skip)).limit(Number(limit));
+    const result = { total, data };
+    return result;
+  }
 }
 
 module.exports = ChatService;