|
|
@ -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, |
|
|
|