运维服务中台
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.

43 lines
1.1 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 anxinStrucRange (ctx) {
try {
const { models } = ctx.fs.dc;
const { userInfo = {} } = ctx.fs.api || {};
const { correlationProject = [] } = userInfo
const bindRes = await models.ProjectCorrelation.findAll({
where: {
pepProjectId: { $in: correlationProject }
}
})
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,
anxinStrucRange
}
}