You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
867 B
33 lines
867 B
3 years ago
|
module.exports = function (app, opts) {
|
||
|
async function getCameraLevel3ByStreamId ({ streamId, errMsg = '' }) {
|
||
|
const { models } = app.fs.dc
|
||
|
if (!streamId) {
|
||
|
errMsg = '参数错误'
|
||
|
throw errMsg
|
||
|
}
|
||
|
|
||
|
const streamIdArr = [streamId]
|
||
|
|
||
|
const findChild = async (streamIdArr) => {
|
||
|
const childRes = await models.GbCamera.findAll({
|
||
|
where: {
|
||
|
parent: { $in: streamIdArr },
|
||
|
}
|
||
|
})
|
||
|
if (!childRes.length || childRes.some(c => c.level == 2)) {
|
||
|
return childRes
|
||
|
} else {
|
||
|
const nextLevelStreamIds = childRes.map(level => level.streamid)
|
||
|
return findChild(nextLevelStreamIds)
|
||
|
}
|
||
|
}
|
||
|
|
||
|
const cameraRes = await findChild(streamIdArr)
|
||
|
|
||
|
return cameraRes
|
||
|
}
|
||
|
|
||
|
return {
|
||
|
getCameraLevel3ByStreamId
|
||
|
}
|
||
|
}
|