|
@ -26,24 +26,35 @@ async function getOrganizationsStruc (ctx) { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
async function getThingsDeploy (ctx) { |
|
|
async function getThingsDeploy (ctx) { |
|
|
try { |
|
|
let error = { name: 'FindError', message: '获取设备部署信息失败' }; |
|
|
const { utils: { anxinStrucIdRange } } = ctx.app.fs |
|
|
let rslt = null, errStatus = null; |
|
|
const { thingId } = ctx.params |
|
|
let { thingId } = ctx.params; |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
if (!thingId) { |
|
|
if (!thingId) { |
|
|
throw '缺少参数 thingId' |
|
|
throw '缺少参数 thingId' |
|
|
} |
|
|
} |
|
|
let iotaResponse = await ctx.app.fs.iotRequest.get(`/things/${thingId}/deploys`) || {} |
|
|
let iotaResponse = await ctx.app.fs.iotRequest.get(`things/${thingId}/deploys`) |
|
|
|
|
|
rslt = iotaResponse |
|
|
ctx.status = 200 |
|
|
error = null; |
|
|
ctx.body = iotaResponse.body |
|
|
|
|
|
|
|
|
|
|
|
} catch (error) { |
|
|
} catch (err) { |
|
|
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); |
|
|
errStatus = err.status |
|
|
ctx.status = 400; |
|
|
ctx.fs.logger.error(`path: ${ctx.path}, error: ${err}`); |
|
|
|
|
|
} |
|
|
|
|
|
if (error) { |
|
|
|
|
|
if (errStatus == 404) { |
|
|
|
|
|
ctx.status = 200; |
|
|
ctx.body = { |
|
|
ctx.body = { |
|
|
message: '获取设备部署信息失败' |
|
|
'instances': null |
|
|
|
|
|
}; |
|
|
|
|
|
} else { |
|
|
|
|
|
ctx.status = errStatus; |
|
|
|
|
|
ctx.body = error; |
|
|
} |
|
|
} |
|
|
|
|
|
} else { |
|
|
|
|
|
ctx.status = 200; |
|
|
|
|
|
ctx.body = rslt; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|