|
|
@ -232,23 +232,30 @@ async function user (ctx) { |
|
|
|
).toPromise() : |
|
|
|
[] |
|
|
|
|
|
|
|
// 查用户绑定的当前系统的项目 id
|
|
|
|
let pomsProjectRes = await models.ProjectCorrelation.findAll({ |
|
|
|
where: { |
|
|
|
id: { $in: pomsProjectIds } |
|
|
|
id: { $in: [...pomsProjectIds] }, |
|
|
|
// del: false
|
|
|
|
} |
|
|
|
}) |
|
|
|
// 获取响应的绑定的 项企项目的 id
|
|
|
|
let pepPojectIds = new Set() |
|
|
|
for (let pid of pomsProjectRes) { |
|
|
|
|
|
|
|
for (let p of pomsProjectRes) { |
|
|
|
if (p.pepProjectId) { |
|
|
|
pepPojectIds.add(p.pepProjectId) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
let pepProjectRes = pomsProjectRes.length ? |
|
|
|
await clickHouse.pepEmis.query(` |
|
|
|
|
|
|
|
// 查对应的项企项目信息
|
|
|
|
let pepProjectRes = pepPojectIds.size ? |
|
|
|
await clickHouse.projectManage.query(` |
|
|
|
SELECT id, project_name, isdelete FROM t_pim_project WHERE id IN (${[...pepPojectIds]}) |
|
|
|
`).toPromise() :
|
|
|
|
[] |
|
|
|
|
|
|
|
// 遍历用户并将查到的信息拼合
|
|
|
|
for (let u of userRes.rows.concat(adminRes)) { |
|
|
|
// 用户信息
|
|
|
|
const corUsers = userPepRes.filter(up => up.id == u.pepUserId) |
|
|
|
u.dataValues.name = corUsers.length ? corUsers[0].name : '' |
|
|
|
u.dataValues.departments = corUsers.length ? corUsers.map(cu => { |
|
|
@ -257,6 +264,26 @@ async function user (ctx) { |
|
|
|
id: cu.depId |
|
|
|
} |
|
|
|
}) : [] |
|
|
|
// pep项目信息
|
|
|
|
u.dataValues.correlationProject = u.dataValues.correlationProject.map(cpid => { |
|
|
|
let returnData = { |
|
|
|
id: cpid, |
|
|
|
} |
|
|
|
const corPomsProject = pomsProjectRes.find(ppr => ppr.id == cpid) |
|
|
|
if (corPomsProject) { |
|
|
|
returnData.name = corPomsProject.name |
|
|
|
returnData.del = corPomsProject.del |
|
|
|
if (corPomsProject.pepProjectId) { |
|
|
|
returnData.pepProjectId = corPomsProject.pepProjectId |
|
|
|
const corPepProject = pepProjectRes.find(ppr => ppr.id == corPomsProject.pepProjectId) |
|
|
|
if (corPepProject) { |
|
|
|
returnData.pepProjectName = corPepProject.project_name |
|
|
|
returnData.pepIsdelete = corPepProject.isdelete |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return returnData |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
ctx.status = 200 |
|
|
|