'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 } }