Commit 0cec34cb by 王昆

gsb

parent 784c8438
......@@ -7,6 +7,7 @@ module.exports = (db, DataTypes) => {
ucname: DataTypes.STRING,
password: DataTypes.STRING,
uctype: DataTypes.INTEGER,
uctypeId: DataTypes.STRING,
org_id: DataTypes.INTEGER,
orgpath: DataTypes.STRING,
isMain: {
......
......@@ -41,8 +41,9 @@ class UserService extends ServiceBase {
}
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) {
return system.getResult(null, "用户名或密码错误");
......@@ -51,6 +52,10 @@ class UserService extends ServiceBase {
return system.getResult(null, "用户已禁用");
}
if(uctype && uctype != user.uctype) {
return system.getResult(null, "用户类型错误");
}
var loginPwd = await this.getEncryptStr(obj.password);
if (loginPwd != user.password) {
return system.getResult(null, "用户名或密码错误");
......@@ -76,6 +81,9 @@ class UserService extends ServiceBase {
// 详情
user.info = await this.userinfoDao.findById(user.id);
// 用户类型 1平台 2商户 3交付商 4个人
var uctype = user.uctype;
// 角色
user.roles = await this.userroleDao.findUserRoles(user.id);
// 构建请求权限接口参数
......@@ -87,10 +95,13 @@ class UserService extends ServiceBase {
roleIds: roleIds,
saas_id: user.saas_id,
}
// 菜单权限
user.menus = await this.authSve.menuByRoleIds(authParams);
// 接口权限
user.auths = await this.authSve.authByRoleIds(authParams);
if (uctype == 1) {
// 菜单权限
user.menus = await this.authSve.menuByRoleIds(authParams);
// 接口权限
user.auths = await this.authSve.authByRoleIds(authParams);
}
}
async add(obj) {
......@@ -100,7 +111,8 @@ class UserService extends ServiceBase {
var ucid = this.trim(obj.ucid);
var ucname = this.trim(obj.ucname);
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 realName = this.trim(obj.realName);
var isMain = obj.isMain || 0;
......@@ -122,6 +134,7 @@ class UserService extends ServiceBase {
ucname: ucname,
password: await this.getEncryptStr(password),
uctype: uctype,
uctypeId: uctypeId,
org_id: org.id || 0,
isMain: isMain,
orgpath: "",
......@@ -169,19 +182,24 @@ class UserService extends ServiceBase {
var roles = obj.roles || [];
var org = obj.org || {};
var uctype = this.trim(obj.uctype);
var uctypeId = this.trim(obj.uctypeId);
var mobile = this.trim(obj.mobile);
var realName = this.trim(obj.realName);
var isMain = obj.isMain || 0;
var user = {
id: id,
uctype: uctype,
uctypeId: uctypeId,
org_id: org.id || "",
orgpath: "",
isMain: obj.isMain || 0,
}
if (user.uctype === 1) {
user.orgpath = isMain ? org.path : org.path + "/" + id;
}
var info = {
id: id,
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