Commit 0cec34cb by 王昆

gsb

parent 784c8438
...@@ -7,6 +7,7 @@ module.exports = (db, DataTypes) => { ...@@ -7,6 +7,7 @@ module.exports = (db, DataTypes) => {
ucname: DataTypes.STRING, ucname: DataTypes.STRING,
password: DataTypes.STRING, password: DataTypes.STRING,
uctype: DataTypes.INTEGER, uctype: DataTypes.INTEGER,
uctypeId: DataTypes.STRING,
org_id: DataTypes.INTEGER, org_id: DataTypes.INTEGER,
orgpath: DataTypes.STRING, orgpath: DataTypes.STRING,
isMain: { isMain: {
......
...@@ -41,8 +41,9 @@ class UserService extends ServiceBase { ...@@ -41,8 +41,9 @@ class UserService extends ServiceBase {
} }
async login(obj) { async login(obj) {
var user = await this.dao.getByUcname(obj.ucname); var uctype = Number(obj.uctype || 0);
var user = await this.dao.getByUcname(obj.ucname);
// 验证登录合法 // 验证登录合法
if (!user) { if (!user) {
return system.getResult(null, "用户名或密码错误"); return system.getResult(null, "用户名或密码错误");
...@@ -51,6 +52,10 @@ class UserService extends ServiceBase { ...@@ -51,6 +52,10 @@ class UserService extends ServiceBase {
return system.getResult(null, "用户已禁用"); return system.getResult(null, "用户已禁用");
} }
if(uctype && uctype != user.uctype) {
return system.getResult(null, "用户类型错误");
}
var loginPwd = await this.getEncryptStr(obj.password); var loginPwd = await this.getEncryptStr(obj.password);
if (loginPwd != user.password) { if (loginPwd != user.password) {
return system.getResult(null, "用户名或密码错误"); return system.getResult(null, "用户名或密码错误");
...@@ -76,6 +81,9 @@ class UserService extends ServiceBase { ...@@ -76,6 +81,9 @@ class UserService extends ServiceBase {
// 详情 // 详情
user.info = await this.userinfoDao.findById(user.id); user.info = await this.userinfoDao.findById(user.id);
// 用户类型 1平台 2商户 3交付商 4个人
var uctype = user.uctype;
// 角色 // 角色
user.roles = await this.userroleDao.findUserRoles(user.id); user.roles = await this.userroleDao.findUserRoles(user.id);
// 构建请求权限接口参数 // 构建请求权限接口参数
...@@ -87,10 +95,13 @@ class UserService extends ServiceBase { ...@@ -87,10 +95,13 @@ class UserService extends ServiceBase {
roleIds: roleIds, roleIds: roleIds,
saas_id: user.saas_id, saas_id: user.saas_id,
} }
// 菜单权限
user.menus = await this.authSve.menuByRoleIds(authParams); if (uctype == 1) {
// 接口权限 // 菜单权限
user.auths = await this.authSve.authByRoleIds(authParams); user.menus = await this.authSve.menuByRoleIds(authParams);
// 接口权限
user.auths = await this.authSve.authByRoleIds(authParams);
}
} }
async add(obj) { async add(obj) {
...@@ -100,7 +111,8 @@ class UserService extends ServiceBase { ...@@ -100,7 +111,8 @@ class UserService extends ServiceBase {
var ucid = this.trim(obj.ucid); var ucid = this.trim(obj.ucid);
var ucname = this.trim(obj.ucname); var ucname = this.trim(obj.ucname);
var password = this.trim(obj.password); var password = this.trim(obj.password);
var uctype = this.trim(obj.uctype); var uctype = Number(obj.uctype || 1);
var uctypeId = this.trim(obj.uctypeId);
var mobile = this.trim(obj.mobile); var mobile = this.trim(obj.mobile);
var realName = this.trim(obj.realName); var realName = this.trim(obj.realName);
var isMain = obj.isMain || 0; var isMain = obj.isMain || 0;
...@@ -122,6 +134,7 @@ class UserService extends ServiceBase { ...@@ -122,6 +134,7 @@ class UserService extends ServiceBase {
ucname: ucname, ucname: ucname,
password: await this.getEncryptStr(password), password: await this.getEncryptStr(password),
uctype: uctype, uctype: uctype,
uctypeId: uctypeId,
org_id: org.id || 0, org_id: org.id || 0,
isMain: isMain, isMain: isMain,
orgpath: "", orgpath: "",
...@@ -169,19 +182,24 @@ class UserService extends ServiceBase { ...@@ -169,19 +182,24 @@ class UserService extends ServiceBase {
var roles = obj.roles || []; var roles = obj.roles || [];
var org = obj.org || {}; var org = obj.org || {};
var uctype = this.trim(obj.uctype); var uctype = this.trim(obj.uctype);
var uctypeId = this.trim(obj.uctypeId);
var mobile = this.trim(obj.mobile); var mobile = this.trim(obj.mobile);
var realName = this.trim(obj.realName); var realName = this.trim(obj.realName);
var isMain = obj.isMain || 0; var isMain = obj.isMain || 0;
var user = { var user = {
id: id, id: id,
uctype: uctype,
uctypeId: uctypeId,
org_id: org.id || "", org_id: org.id || "",
orgpath: "", orgpath: "",
isMain: obj.isMain || 0, isMain: obj.isMain || 0,
} }
if (user.uctype === 1) { if (user.uctype === 1) {
user.orgpath = isMain ? org.path : org.path + "/" + id; user.orgpath = isMain ? org.path : org.path + "/" + id;
} }
var info = { var info = {
id: id, id: id,
mobile: mobile, mobile: mobile,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment