Commit af0c15cf by 王昆

gsb

parent 030a7d63
node_modules/
.vscode/
.idea/
...@@ -131,7 +131,7 @@ class ActionAPI extends APIBase { ...@@ -131,7 +131,7 @@ class ActionAPI extends APIBase {
return system.getResult(null, `组织机构不存在`); return system.getResult(null, `组织机构不存在`);
} }
} }
opResult = this.userSve.add(action_body); opResult = await this.userSve.add(action_body);
break; break;
case "updUser": case "updUser":
if (action_body.uctype === 1) { if (action_body.uctype === 1) {
...@@ -140,28 +140,34 @@ class ActionAPI extends APIBase { ...@@ -140,28 +140,34 @@ class ActionAPI extends APIBase {
return system.getResult(null, `组织机构不存在`); return system.getResult(null, `组织机构不存在`);
} }
} }
opResult = this.userSve.upd(action_body); opResult = await this.userSve.upd(action_body);
break; break;
case "userInfo": case "userInfo":
opResult = this.userSve.info(action_body); opResult = await this.userSve.info(action_body);
break; break;
case "enabled": case "enabled":
opResult = this.userSve.enabled(action_body); opResult = await this.userSve.enabled(action_body);
break; break;
case "delUser": case "delUser":
opResult = this.userSve.delUser(action_body); opResult = await this.userSve.delUser(action_body);
break; break;
case "userPage": case "userPage":
opResult = this.userSve.pageByCondition(action_body); opResult = await this.userSve.pageByCondition(action_body);
break; break;
case "updPassword": case "updPassword":
opResult = this.userSve.updPassword(action_body); opResult = await this.userSve.updPassword(action_body);
break; break;
case "login": case "login":
opResult = this.userSve.login(action_body); opResult = await this.userSve.login(action_body);
break; break;
case "loginByUcid": case "loginByUcid":
opResult = this.userSve.loginByUcid(action_body); opResult = await this.userSve.loginByUcid(action_body);
break;
case "mapUserByIds":
opResult = await this.userSve.mapByIds(action_body);
break;
case "findUsers":
opResult = await this.userSve.findUsers(action_body);
break; break;
} }
return opResult; return opResult;
......
...@@ -15,5 +15,22 @@ class RoleDao extends Dao { ...@@ -15,5 +15,22 @@ class RoleDao extends Dao {
} }
return await this.customQuery(sql.join(" "), params); return await this.customQuery(sql.join(" "), params);
} }
async findIdsByCode(codes, saas_id) {
if(!codes || codes.length == 0) {
return [];
}
let sql = "SELECT id FROM uc_role WHERE code IN (:codes) AND saas_id = :saas_id";
let list = await this.customQuery(sql, {codes: codes, saas_id: saas_id});
let rs = [];
if(!list) {
return rs;
}
for (let item of list) {
rs.push(item.id);
}
return rs;
}
} }
module.exports = RoleDao; module.exports = RoleDao;
\ No newline at end of file
...@@ -135,5 +135,61 @@ class UserDao extends Dao { ...@@ -135,5 +135,61 @@ class UserDao extends Dao {
sql.push("AND t1.orgpath LIKE :orgpath"); sql.push("AND t1.orgpath LIKE :orgpath");
} }
} }
async findMapByIds(ids) {
let result = {};
if (!ids || ids.length == 0) {
return result;
}
let sql = [];
sql.push("SELECT");
sql.push("t1.id, t1.ucid, t1.ucname, t1.uctype, t1.org_id, t1.orgpath,");
sql.push("t1.isMain, t1.saas_id, t1.isEnabled, t1.created_at,");
sql.push("t2.mobile, t2.realName");
sql.push("FROM uc_user t1");
sql.push("INNER JOIN uc_user_info t2 ON t1.id = t2.id");
sql.push("WHERE t1.id IN (:ids)");
var list = await this.customQuery(sql.join(" "), {
ids: ids
});
if (!list || list.length == 0) {
return result;
}
for (var item of list) {
result[item.id] = item;
}
return result;
}
async findUsers(params) {
let sql = [];
sql.push("SELECT");
sql.push("t1.id, t1.ucid, t1.ucname, t1.uctype, t1.org_id, t1.orgpath,");
sql.push("t1.isMain, t1.saas_id, t1.isEnabled, t1.created_at,");
sql.push("t2.mobile, t2.realName");
sql.push("FROM uc_user t1");
sql.push("INNER JOIN uc_user_info t2 ON t1.id = t2.id");
sql.push("INNER JOIN uc_user_role t3 ON t1.id = t3.user_id");
sql.push("WHERE 1 = 1 ");
if(params.roleIds && params.roleIds.length > 0) {
sql.push("AND t3.role_id IN (:roleIds)");
}
if(params.uctype) {
sql.push("AND t1.uctype = :uctype");
}
if(params.saas_id) {
sql.push("AND t1.saas_id = :saas_id");
}
sql.push("GROUP BY t1.id");
var list = await this.customQuery(sql.join(" "), params);
if (!list || list.length == 0) {
return [];
}
return list;
}
} }
module.exports = UserDao; module.exports = UserDao;
\ No newline at end of file
const system = require("../../../system"); const system = require("../../../system");
const ServiceBase = require("../../sve.base") const ServiceBase = require("../../sve.base")
const settings = require("../../../../config/settings") const settings = require("../../../../config/settings")
class UserService extends ServiceBase { class UserService extends ServiceBase {
constructor() { constructor() {
super("user", ServiceBase.getDaoName(UserService)); super("user", ServiceBase.getDaoName(UserService));
...@@ -9,12 +10,14 @@ class UserService extends ServiceBase { ...@@ -9,12 +10,14 @@ class UserService extends ServiceBase {
this.authSve = system.getObject("service.auth.authSve"); this.authSve = system.getObject("service.auth.authSve");
this.roleDao = system.getObject("db.role.roleDao");
} }
/** /**
* 条件查询 * 条件查询
* @param {*} params * @param {*} params
*/ */
async apiFindUserBySaasId(params) { async apiFindUserBySaasId(params) {
try { try {
...@@ -26,9 +29,9 @@ class UserService extends ServiceBase { ...@@ -26,9 +29,9 @@ class UserService extends ServiceBase {
/** /**
* 根据path查询所有的用户 * 根据path查询所有的用户
* @param {*} params * @param {*} params
*/ */
async apiQueryUserByPath(params){ async apiQueryUserByPath(params) {
try { try {
return await this.queryUserByPath(params); return await this.queryUserByPath(params);
} catch (error) { } catch (error) {
...@@ -41,7 +44,7 @@ class UserService extends ServiceBase { ...@@ -41,7 +44,7 @@ class UserService extends ServiceBase {
/** /**
* 条件查询 * 条件查询
* @param {*} params * @param {*} params
*/ */
async findUserBySaasId(params) { async findUserBySaasId(params) {
try { try {
...@@ -64,7 +67,7 @@ class UserService extends ServiceBase { ...@@ -64,7 +67,7 @@ class UserService extends ServiceBase {
return system.getResult(null, "用户已禁用"); return system.getResult(null, "用户已禁用");
} }
if(uctype && uctype != user.uctype) { if (uctype && uctype != user.uctype) {
return system.getResult(null, "用户类型错误"); return system.getResult(null, "用户类型错误");
} }
...@@ -269,7 +272,7 @@ class UserService extends ServiceBase { ...@@ -269,7 +272,7 @@ class UserService extends ServiceBase {
}; };
var currentPage = Number(params.currentPage || 1); var currentPage = Number(params.currentPage || 1);
var pageSize = Number(params.pageSize || 10); var pageSize = Number(params.pageSize || 10);
if(params.orgpath) { if (params.orgpath) {
params.orgpath = params.orgpath + "%"; params.orgpath = params.orgpath + "%";
} }
...@@ -313,5 +316,24 @@ class UserService extends ServiceBase { ...@@ -313,5 +316,24 @@ class UserService extends ServiceBase {
await user.save(); await user.save();
return system.getResultSuccess(); return system.getResultSuccess();
} }
async mapByIds(params) {
let rs = await this.dao.findMapByIds(params.ids);
return system.getResultSuccess(rs);
}
async findUsers(params) {
if(params.roleCodes && params.roleCodes.length > 0) {
var roleIds = await this.roleDao.findIdsByCode(params.roleCodes, params.saas_id);
if (!roleIds) {
return [];
}
params.roleIds = roleIds;
}
let rs = await this.dao.findUsers(params);
return system.getResultSuccess(rs);
}
} }
module.exports = UserService; module.exports = UserService;
\ No newline at end of file
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