Browse Source

用户姓名、部门

release_0.0.2
巴林闲侠 2 years ago
parent
commit
ea528ba8d2
  1. 9
      api/app/lib/controllers/organization/index.js

9
api/app/lib/controllers/organization/index.js

@ -193,12 +193,17 @@ async function user (ctx) {
for (let u of userRes.rows.concat(adminRes)) { for (let u of userRes.rows.concat(adminRes)) {
userIds.add(u.pepUserId) userIds.add(u.pepUserId)
} }
let userPepRes = await clickHouse.pepEmis.query(`SELECT user.id AS id, "user"."name" AS name, department.name AS depName FROM department_user LEFT JOIN user ON department_user.user=user.id LEFT JOIN department ON department.id=department_user.department WHERE user.id IN (${[...userIds].join(',')})`).toPromise() let userPepRes = await clickHouse.pepEmis.query(`SELECT user.id AS id, "user"."name" AS name, department.name AS depName, department.id AS depId FROM department_user LEFT JOIN user ON department_user.user=user.id LEFT JOIN department ON department.id=department_user.department WHERE user.id IN (${[...userIds].join(',')})`).toPromise()
for (let u of userRes.rows.concat(adminRes)) { for (let u of userRes.rows.concat(adminRes)) {
const corUsers = userPepRes.filter(up => up.id == u.pepUserId) const corUsers = userPepRes.filter(up => up.id == u.pepUserId)
u.dataValues.name = corUsers[0].name u.dataValues.name = corUsers[0].name
u.dataValues.departments = corUsers.map(cu => cu.depName) u.dataValues.departments = corUsers.map(cu => {
return {
name: cu.depName,
id: cu.depId
}
})
} }
ctx.status = 200 ctx.status = 200

Loading…
Cancel
Save