'use strict'; const moment = require('moment') async function getOrganizationsStruc (ctx) { try { const { utils: { anxinStrucIdRange } } = ctx.app.fs const { pepProjectId } = ctx.params if (!pepProjectId) { throw '缺少参数 pepProjectId' } let anxinStruc = await anxinStrucIdRange({ ctx, pepProjectId }) || [] ctx.status = 200 ctx.body = anxinStruc } catch (error) { ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); ctx.status = 400; ctx.body = { message: '获取项目下的结构物信息失败' } } } async function getThingsDeploy (ctx) { let error = { name: 'FindError', message: '获取设备部署信息失败' }; let rslt = null, errStatus = null; let { thingId } = ctx.params; try { if (!thingId) { throw '缺少参数 thingId' } let iotaResponse = await ctx.app.fs.iotRequest.get(`things/${thingId}/deploys`) rslt = iotaResponse error = null; } catch (err) { errStatus = err.status ctx.fs.logger.error(`path: ${ctx.path}, error: ${err}`); } if (error) { if (errStatus == 404) { ctx.status = 200; ctx.body = { 'instances': null }; } else { ctx.status = errStatus; ctx.body = error; } } else { ctx.status = 200; ctx.body = rslt; } } module.exports = { getOrganizationsStruc, getThingsDeploy, }