Browse Source

删除设备 删除推送配置相关

release_1.1.2
巴林闲侠 3 years ago
parent
commit
ed0e95ad5b
  1. 7
      code/VideoAccess-VCMP/api/app/lib/controllers/camera/index.js
  2. 29
      code/VideoAccess-VCMP/api/app/lib/controllers/status/push.js

7
code/VideoAccess-VCMP/api/app/lib/controllers/camera/index.js

@ -310,20 +310,23 @@ async function del (ctx) {
const { cameraId } = ctx.params const { cameraId } = ctx.params
const { token } = ctx.fs.api const { token } = ctx.fs.api
await models.CameraStatusPushMonitor.destroy({
where: {
cameraId: cameraId
}
})
await models.CameraAbilityBind.destroy({ await models.CameraAbilityBind.destroy({
where: { where: {
cameraId: cameraId cameraId: cameraId
}, },
transaction transaction
}) })
await models.CameraRemark.destroy({ await models.CameraRemark.destroy({
where: { where: {
cameraId: cameraId cameraId: cameraId
}, },
transaction transaction
}) })
await models.Camera.destroy({ await models.Camera.destroy({
where: { where: {
id: cameraId id: cameraId

29
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 { userId, token } = ctx.fs.api
const { limit, page, orderBy, orderDirection, name, pushWay } = ctx.query const { limit, page, orderBy, orderDirection, name, pushWay } = ctx.query
const sequelize = ctx.fs.dc.ORM;
let findOption = { let findOption = {
where: {}, where: {},
order: [ order: [
@ -155,21 +154,6 @@ async function get (ctx) {
delete findOption.offset delete findOption.offset
const configIds = configLimitRes.map(c => c.id) const configIds = configLimitRes.map(c => c.id)
findOption.where.id = { $in: configIds } 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 = [ findOption.order = [
[orderBy || 'id', orderDirection || 'DESC'] [orderBy || 'id', orderDirection || 'DESC']
] ]
@ -186,7 +170,7 @@ async function get (ctx) {
}, },
{ {
model: models.CameraStatusPushLog, model: models.CameraStatusPushLog,
attributes: [], attributes: ['id'],
duplicating: false, duplicating: false,
required: false, required: false,
}, },
@ -200,14 +184,17 @@ async function get (ctx) {
const configRes = await models.CameraStatusPushConfig.findAll(findOption) const configRes = await models.CameraStatusPushConfig.findAll(findOption)
delete findOption.attributes
delete findOption.group
delete findOption.order delete findOption.order
delete findOption.distinct
delete findOption.subQuery
delete findOption.include delete findOption.include
delete findOption.where.id delete findOption.where.id
const count = await models.CameraStatusPushConfig.count(findOption) 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.status = 200;
ctx.body = { ctx.body = {
count: count, count: count,

Loading…
Cancel
Save