diff --git a/code/VideoAccess-VCMP/api/app/lib/controllers/camera/index.js b/code/VideoAccess-VCMP/api/app/lib/controllers/camera/index.js index c465c20..5c47d3b 100644 --- a/code/VideoAccess-VCMP/api/app/lib/controllers/camera/index.js +++ b/code/VideoAccess-VCMP/api/app/lib/controllers/camera/index.js @@ -310,20 +310,23 @@ async function del (ctx) { const { cameraId } = ctx.params const { token } = ctx.fs.api + await models.CameraStatusPushMonitor.destroy({ + where: { + cameraId: cameraId + } + }) await models.CameraAbilityBind.destroy({ where: { cameraId: cameraId }, transaction }) - await models.CameraRemark.destroy({ where: { cameraId: cameraId }, transaction }) - await models.Camera.destroy({ where: { id: cameraId diff --git a/code/VideoAccess-VCMP/api/app/lib/controllers/status/push.js b/code/VideoAccess-VCMP/api/app/lib/controllers/status/push.js index d508f1d..c3625b2 100644 --- a/code/VideoAccess-VCMP/api/app/lib/controllers/status/push.js +++ b/code/VideoAccess-VCMP/api/app/lib/controllers/status/push.js @@ -125,7 +125,6 @@ async function get (ctx) { const { userId, token } = ctx.fs.api const { limit, page, orderBy, orderDirection, name, pushWay } = ctx.query - const sequelize = ctx.fs.dc.ORM; let findOption = { where: {}, order: [ @@ -155,21 +154,6 @@ async function get (ctx) { delete findOption.offset const configIds = configLimitRes.map(c => c.id) findOption.where.id = { $in: configIds } - findOption.attributes = { - include: [ - [sequelize.fn('COUNT', sequelize.col('cameraStatusPushMonitors.id')), 'monitorCount'], - [sequelize.fn('COUNT', sequelize.col('cameraStatusPushLogs.id')), 'logCount'] - ], - } - findOption.distinct = true - findOption.subQuery = false - findOption.group = [ - 'cameraStatusPushConfig.id', - 'cameraStatusPushMonitors.id', - 'cameraStatusPushLogs.id', - 'cameraStatusPushReceivers.id', - 'cameraStatusPushMonitors->camera.id', - ] findOption.order = [ [orderBy || 'id', orderDirection || 'DESC'] ] @@ -186,7 +170,7 @@ async function get (ctx) { }, { model: models.CameraStatusPushLog, - attributes: [], + attributes: ['id'], duplicating: false, required: false, }, @@ -200,14 +184,17 @@ async function get (ctx) { const configRes = await models.CameraStatusPushConfig.findAll(findOption) - delete findOption.attributes - delete findOption.group delete findOption.order - delete findOption.distinct - delete findOption.subQuery delete findOption.include delete findOption.where.id const count = await models.CameraStatusPushConfig.count(findOption) + + for (let { dataValues: c } of configRes) { + c.monitorCount = c.cameraStatusPushMonitors.length; + c.logCount = c.cameraStatusPushLogs.length; + delete c.cameraStatusPushLogs + } + ctx.status = 200; ctx.body = { count: count,