liuyu há 4 anos atrás
pai
commit
d98ebff828
3 ficheiros alterados com 13 adições e 1 exclusões
  1. 5 0
      app/controller/user.js
  2. 1 1
      app/router.js
  3. 7 0
      app/service/user.js

+ 5 - 0
app/controller/user.js

@@ -32,6 +32,11 @@ class UserController extends Controller {
     const res = await this.service.bind(this.ctx.request.body);
     this.ctx.ok({ data: res });
   }
+
+  async finduserlist() {
+    const res = await this.service.finduserlist(this.ctx.query);
+    this.ctx.ok({ ...res });
+  }
 }
 
 module.exports = CrudController(UserController, meta);

+ 1 - 1
app/router.js

@@ -9,7 +9,7 @@ module.exports = app => {
 
   // 取得用户权限列表
   router.get('/api/auth/user/menus', controller.user.querymenus);
-
+  router.get('/api/auth/user/finduserlist', controller.user.finduserlist);
   // 权限表设置路由
   router.resources('role', '/api/auth/role', controller.role); // index、create、show、destroy
   router.post('role', '/api/auth/role/update/:id', controller.role.update);

+ 7 - 0
app/service/user.js

@@ -140,6 +140,13 @@ class UserService extends CrudService {
     return user;
   }
 
+  async finduserlist({ skip, limit, ...info }) {
+    const query = { ...info, $or: [{ role: '2' }, { role: '3' }, { role: '6' }] };
+    const total = await this.model.count(query);
+    const data = await this.model.find(query).skip(Number(skip)).limit(Number(limit));
+    return { data, total };
+  }
+
 }
 
 module.exports = UserService;