You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
50 lines
1.4 KiB
50 lines
1.4 KiB
'use strict';
|
|
const fs = require('fs');
|
|
const moment = require('moment')
|
|
|
|
module.exports = function (app, opts) {
|
|
|
|
function judgeSuper (ctx) {
|
|
try {
|
|
const { userInfo = {} } = ctx.fs.api || {};
|
|
const { role = [] } = userInfo
|
|
return role.includes('SuperAdmin')
|
|
} catch (error) {
|
|
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`);
|
|
}
|
|
}
|
|
|
|
async function anxinStrucIdRange ({ ctx, pepProjectId }) {
|
|
try {
|
|
const { models } = ctx.fs.dc;
|
|
const { userInfo = {} } = ctx.fs.api || {};
|
|
const { correlationProject = [] } = userInfo
|
|
|
|
// TODO 这儿也许需要判断传进来的 pepProjectId 在不在当前用户的关注范围内
|
|
const bindRes = await models.ProjectCorrelation.findAll({
|
|
where: {
|
|
id: { $in: pepProjectId ? [pepProjectId] : correlationProject },
|
|
del: false
|
|
}
|
|
})
|
|
return [
|
|
...bindRes.reduce(
|
|
(arr, b) => {
|
|
for (let sid of b.anxinProjectId) {
|
|
arr.add(sid);
|
|
}
|
|
return arr;
|
|
},
|
|
new Set()
|
|
)
|
|
]
|
|
} catch (error) {
|
|
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`);
|
|
}
|
|
}
|
|
|
|
return {
|
|
judgeSuper,
|
|
anxinStrucIdRange
|
|
}
|
|
}
|