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.
55 lines
1.2 KiB
55 lines
1.2 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) {
|
|
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,
|
|
}
|