Browse Source

设备筛选

pull/3/head
yuan_yi 2 years ago
parent
commit
a033e13a2e
  1. 18
      code/VideoAccess-VCMP/api/app/lib/controllers/camera/index.js
  2. 8
      code/VideoAccess-VCMP/api/app/lib/controllers/nvr/index.js

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

@ -3,7 +3,7 @@
async function getCameraProject (ctx, next) {
try {
const models = ctx.fs.dc.models;
const { limit, page, orderBy, orderDirection } = ctx.query
const { limit, page, orderBy, orderDirection, keyword, abilityId, type, venderId } = ctx.query
const { userId, token } = ctx.fs.api
let findOption = {
@ -28,6 +28,22 @@ async function getCameraProject (ctx, next) {
if (page && limit) {
findOption.offset = page * limit
}
if (keyword) {
findOption.where.$or = [{
name: { $like: `%${keyword}%` }
}, {
serialNo: { $like: `%${keyword}%` }
}]
}
if (type) {
findOption.where.type = type
}
if (abilityId) {
findOption.where.abilityId = abilityId
}
if (venderId) {
findOption.where.venderId = venderId
}
const cameraRes = await models.Camera.findAll(findOption)
const total = await models.Camera.count({

8
code/VideoAccess-VCMP/api/app/lib/controllers/nvr/index.js

@ -47,7 +47,7 @@ async function get (ctx) {
const models = ctx.fs.dc.models;
try {
const { userId, token } = ctx.fs.api
const { limit, page, orderBy, orderDirection } = ctx.query
const { limit, page, orderBy, orderDirection, keyword, venderId } = ctx.query
let findOption = {
attributes: { exclude: ['delete'] },
where: {
@ -64,6 +64,12 @@ async function get (ctx) {
if (page && limit) {
findOption.offset = page * limit
}
if (keyword) {
findOption.where.name = { $like: `%${keyword}%` }
}
if (venderId) {
findOption.where.venderId = venderId
}
const res = await models.Nvr.findAll(findOption)
const total = await models.Nvr.count({

Loading…
Cancel
Save