明树Git Lab

Commit a7cb8cb4 authored by zfp1's avatar zfp1

update

parent 6482a79e
......@@ -34,7 +34,7 @@ async function login(req, res, next) {
include: [{
model: DB.Role,
as: 'roles',
where: { del: 0 },
// where: { del: 0 },
attributes: ["id", "name"],
through: { attributes: [] },
include: [{
......@@ -44,10 +44,11 @@ async function login(req, res, next) {
// attributes: ['id', 'name', 'parentId'],
through: { attributes: [] },
}]
}, {
},
{
model: DB.Depart,
as: 'departs',
where: { del: 0 },
// where: { del: 0 }, 当刚注册的用户 没有分配角色、部门时加上条件会查不到
attributes: ["id", "name"],
through: { attributes: [] },
}
......@@ -82,7 +83,7 @@ async function login(req, res, next) {
delete element.menus;
newRoles.push(element);
}
user.roles = roles || [];
user.roles = newRoles || [];
user.menus = utils.buildTree(menus);
return res.sendData(user);
} catch (error) {
......@@ -176,13 +177,13 @@ async function updateUser(req, res, next) {
}
if (body.departs && body.departs.length) {
//跟现有情况对比 确定增删关系
const departIds = body.departs.map(o => {return o && o.id || o});
const departIds = body.departs.map(o => { return o && o.id || o });
await userModule.setUserDepart(user.id, departIds, user.departs);
delete body.departs;
}
if (body.roles && body.roles.length) {
//跟现有情况对比 确定增删关系
const roleIds = body.roles.map(o => {return o && o.id || o});
const roleIds = body.roles.map(o => { return o && o.id || o });
await userModule.setUserRole(user.id, roleIds, user.roles);
delete body.roles;
}
......
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