|
@ -1,12 +1,10 @@ |
|
|
'use strict'; |
|
|
'use strict'; |
|
|
|
|
|
|
|
|
async function get (ctx, next) { |
|
|
async function getCameraProject (ctx, next) { |
|
|
try { |
|
|
try { |
|
|
const models = ctx.fs.dc.models; |
|
|
const models = ctx.fs.dc.models; |
|
|
const { limit, page, orderBy, orderDirection } = ctx.query |
|
|
const { limit, page, orderBy, orderDirection } = ctx.query |
|
|
const { userId } = ctx.fs.api |
|
|
const { userId, token } = ctx.fs.api |
|
|
|
|
|
|
|
|
const aa = await ctx.app.fs.axyRequest.get('structures/types', { query: { token: 'b11b7e6d-032e-4e3e-8973-931c2c5ada5a' } }) |
|
|
|
|
|
|
|
|
|
|
|
let findOption = { |
|
|
let findOption = { |
|
|
attributes: { exclude: ['delete', 'recycleTime',] }, |
|
|
attributes: { exclude: ['delete', 'recycleTime',] }, |
|
@ -32,6 +30,55 @@ async function get (ctx, next) { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
const cameraRes = await models.Camera.findAll(findOption) |
|
|
const cameraRes = await models.Camera.findAll(findOption) |
|
|
|
|
|
const total = await models.Camera.count({ |
|
|
|
|
|
where: findOption.where |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
// 查在安心云绑定的数据
|
|
|
|
|
|
const cameraIds = cameraRes.map(c => { |
|
|
|
|
|
return c.dataValues.id |
|
|
|
|
|
}) |
|
|
|
|
|
const axbindCameraRes = await ctx.app.fs.axyRequest.get('vcmp/camera/project', { query: { token, cameraId: cameraIds.join(',') } }) |
|
|
|
|
|
|
|
|
|
|
|
for (let { dataValues: camera } of cameraRes) { |
|
|
|
|
|
const corBindCamera = axbindCameraRes.find(b => b.cameraId == camera.id) |
|
|
|
|
|
if (corBindCamera) { |
|
|
|
|
|
camera.station = corBindCamera.stations |
|
|
|
|
|
} else { |
|
|
|
|
|
camera.station = [] |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
ctx.status = 200; |
|
|
|
|
|
ctx.body = { |
|
|
|
|
|
total: total, |
|
|
|
|
|
data: cameraRes |
|
|
|
|
|
} |
|
|
|
|
|
} catch (error) { |
|
|
|
|
|
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); |
|
|
|
|
|
ctx.status = 400; |
|
|
|
|
|
ctx.body = {} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
async function getCamera (ctx) { |
|
|
|
|
|
try { |
|
|
|
|
|
const { models } = ctx.fs.dc; |
|
|
|
|
|
const { cameraId } = ctx.query |
|
|
|
|
|
|
|
|
|
|
|
const cameraRes = await models.Camera.findAll({ |
|
|
|
|
|
attributes: { exclude: ['delete', 'recycleTime',] }, |
|
|
|
|
|
where: { |
|
|
|
|
|
id: { $in: cameraId.split(',') } |
|
|
|
|
|
}, |
|
|
|
|
|
include: [{ |
|
|
|
|
|
model: models.CameraAbility |
|
|
|
|
|
}, { |
|
|
|
|
|
model: models.CameraKind |
|
|
|
|
|
}, { |
|
|
|
|
|
model: models.Vender |
|
|
|
|
|
}] |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
ctx.status = 200; |
|
|
ctx.status = 200; |
|
|
ctx.body = cameraRes |
|
|
ctx.body = cameraRes |
|
@ -42,6 +89,55 @@ async function get (ctx, next) { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
async function banned (ctx) { |
|
|
|
|
|
try { |
|
|
|
|
|
const { models } = ctx.fs.dc; |
|
|
|
|
|
const data = ctx.request.body; |
|
|
|
|
|
|
|
|
|
|
|
// 向视频服务发送通知
|
|
|
|
|
|
|
|
|
|
|
|
// 库记录
|
|
|
|
|
|
await models.Camera.update({ |
|
|
|
|
|
forbidden: data.forbidden |
|
|
|
|
|
}, { |
|
|
|
|
|
where: { |
|
|
|
|
|
id: data.cameraId |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
ctx.status = 204; |
|
|
|
|
|
} catch (error) { |
|
|
|
|
|
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); |
|
|
|
|
|
ctx.status = 400; |
|
|
|
|
|
ctx.body = {} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
async function del (ctx) { |
|
|
|
|
|
try { |
|
|
|
|
|
const { models } = ctx.fs.dc; |
|
|
|
|
|
const { cameraId } = ctx.query |
|
|
|
|
|
const { token } = ctx.fs.api |
|
|
|
|
|
|
|
|
|
|
|
await models.cameraId.destroy({ |
|
|
|
|
|
where: { |
|
|
|
|
|
id: cameraId |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
await ctx.app.fs.axyRequest.delete('vcmp/camera/project', { query: { token, cameraId: cameraId.join(',') } }) |
|
|
|
|
|
|
|
|
|
|
|
ctx.status = 204; |
|
|
|
|
|
} catch (error) { |
|
|
|
|
|
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); |
|
|
|
|
|
ctx.status = 400; |
|
|
|
|
|
ctx.body = {} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
module.exports = { |
|
|
module.exports = { |
|
|
get, |
|
|
getCameraProject, |
|
|
|
|
|
getCamera, |
|
|
|
|
|
banned, |
|
|
|
|
|
del, |
|
|
}; |
|
|
}; |