liuyu 4 gadi atpakaļ
vecāks
revīzija
738fa1bece
3 mainītis faili ar 12 papildinājumiem un 0 dzēšanām
  1. 5 0
      app/controller/lookuser.js
  2. 1 0
      app/router.js
  3. 6 0
      app/service/lookuser.js

+ 5 - 0
app/controller/lookuser.js

@@ -23,6 +23,11 @@ class LookuserController extends Controller {
     this.ctx.ok({ ...data });
   }
 
+  async swichrole() {
+    const res = await this.service.userswichrole(this.ctx.query);
+    this.ctx.ok({ data: res });
+  }
+
 }
 
 module.exports = CrudController(LookuserController, meta);

+ 1 - 0
app/router.js

@@ -33,6 +33,7 @@ module.exports = app => {
 
   // 观看用户表设置路由
   router.get('/api/onlive/lookuser/roomcount', controller.lookuser.roomcount);
+  router.get('/api/onlive/lookuser/swichrole', controller.lookuser.swichrole);
   router.resources('lookuser', '/api/onlive/lookuser', controller.lookuser); // index、create、show、destroy
   router.post('lookuser', '/api/onlive/lookuser/update/:id', controller.lookuser.update);
 

+ 6 - 0
app/service/lookuser.js

@@ -49,6 +49,12 @@ class LookuserService extends CrudService {
     const total = await this.model.count({ roomname });
     return { total };
   }
+
+  async userswichrole(data) {
+    const { roomid, userid } = data;
+    const res = await this.model.findOne({ roomid, userid });
+    return res;
+  }
 }
 
 module.exports = LookuserService;