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

66 lines
1.5 KiB

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