'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) { try { const { utils: { anxinStrucIdRange } } = ctx.app.fs const { thingId } = ctx.params if (!thingId) { throw '缺少参数 thingId' } let iotaResponse = await ctx.app.fs.iotRequest.get(`/things/${thingId}/deploys`) || {} ctx.status = 200 ctx.body = iotaResponse.body } catch (error) { ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); ctx.status = 400; ctx.body = { message: '获取设备部署信息失败' } } } module.exports = { getOrganizationsStruc, getThingsDeploy, }