Browse Source

加入专家角色

liuyu 5 years ago
parent
commit
3384e63865
2 changed files with 13 additions and 1 deletions
  1. 1 1
      app/model/user.js
  2. 12 0
      app/service/login.js

+ 1 - 1
app/model/user.js

@@ -10,7 +10,7 @@ const UserSchema = {
   passwd: { type: Secret, select: false }, // 注册密码
   openid: { type: String, required: false }, // 微信openid
   uid: { type: String, required: false }, // 用户信息id
-  role: { type: String, required: false }, // 1-管理员,2-个人,3-企业管理员,4-子管理员
+  role: { type: String, required: false }, // 1-管理员,2-个人,3-企业管理员,4-子管理员,5、专家
   menus: { type: [ String ], required: false }, // 菜单权限
   remark: { type: String, required: false }, // 备注
 };

+ 12 - 0
app/service/login.js

@@ -43,6 +43,18 @@ class LoginService extends CrudService {
       if (marketuser.data.data.status !== '1') {
         throw new BusinessError(ErrorCode.ACCESS_DENIED);
       }
+    } else if (_user.role === '5') {
+      const url = 'http://127.0.0.1:9004/api/market/expertsuser/' + _user.uid;
+      const expertsuser = await this.ctx.curl(url, {
+        method: 'get',
+        headers: {
+          'content-type': 'application/json',
+        },
+        dataType: 'json',
+      });
+      if (expertsuser.data.data.status !== '1') {
+        throw new BusinessError(ErrorCode.ACCESS_DENIED);
+      }
     }
     // 取出用户的类型,根据用户类型返回相应信息
     const state = uuid();