|
|
@ -5,7 +5,7 @@ const moment = require('moment') |
|
|
|
async function getCameraProject (ctx, next) { |
|
|
|
try { |
|
|
|
const models = ctx.fs.dc.models; |
|
|
|
const { limit, page, orderBy, orderDirection, keyword, abilityId, type, venderId, nvrId } = ctx.query |
|
|
|
const { limit, page, orderBy, orderDirection, keyword, abilityId, type, venderId, nvrId, externalDomain } = ctx.query |
|
|
|
const { userId, token } = ctx.fs.api |
|
|
|
|
|
|
|
let findOption = { |
|
|
@ -36,11 +36,14 @@ async function getCameraProject (ctx, next) { |
|
|
|
findOption.offset = page * limit |
|
|
|
} |
|
|
|
if (keyword) { |
|
|
|
findOption.where.$or = [{ |
|
|
|
findOption.where.$or = [ |
|
|
|
{ |
|
|
|
name: { $like: `%${keyword}%` } |
|
|
|
}, { |
|
|
|
serialNo: { $like: `%${keyword}%` } |
|
|
|
}] |
|
|
|
}, |
|
|
|
// {
|
|
|
|
// serialNo: { $like: `%${keyword}%` }
|
|
|
|
// }
|
|
|
|
] |
|
|
|
} |
|
|
|
if (type) { |
|
|
|
findOption.where.type = type |
|
|
@ -53,6 +56,9 @@ async function getCameraProject (ctx, next) { |
|
|
|
abilityId: abilityId |
|
|
|
} |
|
|
|
} |
|
|
|
if (externalDomain) { |
|
|
|
findOption.where.externalDomain = externalDomain |
|
|
|
} |
|
|
|
|
|
|
|
findOption.include.push(abilityFind) |
|
|
|
const cameraRes = await models.Camera.findAll(findOption) |
|
|
@ -80,12 +86,10 @@ async function getCameraProject (ctx, next) { |
|
|
|
: [] |
|
|
|
|
|
|
|
for (let { dataValues: camera } of cameraRes) { |
|
|
|
const corBindCamera = axbindCameraRes.find(b => b.cameraId == camera.id) |
|
|
|
if (corBindCamera) { |
|
|
|
camera.station = corBindCamera.stations |
|
|
|
} else { |
|
|
|
camera.station = [] |
|
|
|
} |
|
|
|
const corBindCamera = axbindCameraRes.filter(b => b.cameraId == camera.id) |
|
|
|
camera.station = corBindCamera.reduce((station, c) => { |
|
|
|
return station.concat.apply(station, c.stations) |
|
|
|
}, []) |
|
|
|
const corUser = corUsers.find(u => u.id == camera.createUserId) |
|
|
|
|
|
|
|
camera.createUser = { |
|
|
|