|
@ -235,7 +235,7 @@ async function creatUser(ctx, next) { |
|
|
delete: false, |
|
|
delete: false, |
|
|
phone: data.phone, |
|
|
phone: data.phone, |
|
|
post: data.post, |
|
|
post: data.post, |
|
|
structure:data.structure |
|
|
structure: data.structure |
|
|
}) |
|
|
}) |
|
|
|
|
|
|
|
|
ctx.status = 204; |
|
|
ctx.status = 204; |
|
@ -276,7 +276,7 @@ async function updateUser(ctx, next) { |
|
|
delete: false, |
|
|
delete: false, |
|
|
phone: data.phone, |
|
|
phone: data.phone, |
|
|
post: data.post, |
|
|
post: data.post, |
|
|
structure:data.structure |
|
|
structure: data.structure |
|
|
}, { |
|
|
}, { |
|
|
where: { |
|
|
where: { |
|
|
id: id |
|
|
id: id |
|
@ -376,6 +376,41 @@ async function updateUserPassword(ctx, next) { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
async function getStructuresUsers(ctx, next) { |
|
|
|
|
|
try { |
|
|
|
|
|
const models = ctx.fs.dc.models; |
|
|
|
|
|
|
|
|
|
|
|
let userRes = await models.User.findAll({ |
|
|
|
|
|
where: { |
|
|
|
|
|
delete: false |
|
|
|
|
|
}, |
|
|
|
|
|
attributes: ['id', 'name', 'username', 'structure'], |
|
|
|
|
|
order: [['id', 'asc']] |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
let structs = await models.Project.findAll({ |
|
|
|
|
|
where: {}, |
|
|
|
|
|
attributes: ['id', 'name',], |
|
|
|
|
|
order: [['id', 'asc']], |
|
|
|
|
|
}) |
|
|
|
|
|
const rslt = []; |
|
|
|
|
|
structs.map(s => { |
|
|
|
|
|
rslt.push({ |
|
|
|
|
|
id: s.id, |
|
|
|
|
|
name: s.name, |
|
|
|
|
|
users: userRes.filter(x => x.structure && x.structure.find(v => v == s.id)).map(d => { return { id: d.id, name: d.name } }) |
|
|
|
|
|
}); |
|
|
|
|
|
}) |
|
|
|
|
|
ctx.status = 200; |
|
|
|
|
|
ctx.body = rslt |
|
|
|
|
|
} catch (error) { |
|
|
|
|
|
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); |
|
|
|
|
|
ctx.status = 400; |
|
|
|
|
|
ctx.body = { |
|
|
|
|
|
"message": "获取用户信息失败" |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
module.exports = { |
|
|
module.exports = { |
|
|
getDepMessage, |
|
|
getDepMessage, |
|
@ -387,5 +422,6 @@ module.exports = { |
|
|
updateUser, |
|
|
updateUser, |
|
|
deleteUser, |
|
|
deleteUser, |
|
|
resetPwd, |
|
|
resetPwd, |
|
|
updateUserPassword |
|
|
updateUserPassword, |
|
|
|
|
|
getStructuresUsers |
|
|
} |
|
|
} |