From 538fb4630a66702c263f2d4318f4ccf32e230982 Mon Sep 17 00:00:00 2001 From: yuan_yi <1650192445@qq.com> Date: Thu, 2 Jun 2022 14:26:12 +0800 Subject: [PATCH 1/2] import react --- .../api/app/lib/controllers/camera/index.js | 22 ++++++++++++++----- .../api/app/lib/routes/camera/index.js | 4 ++-- .../src/components/simpleFileDownButton.jsx | 4 +++- .../src/sections/auth/containers/login.jsx | 10 +++++++++ .../components/skeletonScreen.jsx | 1 + code/VideoAccess-VCMP/web/webpack.config.js | 4 +++- 6 files changed, 36 insertions(+), 9 deletions(-) diff --git a/code/VideoAccess-VCMP/api/app/lib/controllers/camera/index.js b/code/VideoAccess-VCMP/api/app/lib/controllers/camera/index.js index 4efc107..f1a4370 100644 --- a/code/VideoAccess-VCMP/api/app/lib/controllers/camera/index.js +++ b/code/VideoAccess-VCMP/api/app/lib/controllers/camera/index.js @@ -221,23 +221,35 @@ async function banned (ctx) { } async function del (ctx) { + const transaction = await ctx.fs.dc.orm.transaction(); try { const { models } = ctx.fs.dc; - const { cameraId } = ctx.query + const { cameraId } = ctx.params const { token } = ctx.fs.api - await models.cameraId.destroy({ + await models.CameraAbilityBind.destroy({ + where: { + cameraId: cameraId + }, + transaction + }) + + await models.Camera.destroy({ where: { id: cameraId - } + }, + transaction }) - if (cameraId.length) { - await ctx.app.fs.axyRequest.delete('vcmp/camera/project', { query: { token, cameraId: cameraId.join(',') } }) + + if (cameraId) { + await ctx.app.fs.axyRequest.delete('vcmp/camera/project', { query: { token, cameraId: cameraId } }) } + await transaction.commit(); ctx.status = 204; } catch (error) { + await transaction.rollback(); ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); ctx.status = 400; ctx.body = {} diff --git a/code/VideoAccess-VCMP/api/app/lib/routes/camera/index.js b/code/VideoAccess-VCMP/api/app/lib/routes/camera/index.js index 702be70..ba98441 100644 --- a/code/VideoAccess-VCMP/api/app/lib/routes/camera/index.js +++ b/code/VideoAccess-VCMP/api/app/lib/routes/camera/index.js @@ -35,8 +35,8 @@ module.exports = function (app, router, opts) { app.fs.api.logAttr['PUT/camera/banned'] = { content: '禁用摄像头', visible: false }; router.put('/camera/banned', camera.banned); - app.fs.api.logAttr['DEL/camera'] = { content: '删除摄像头', visible: false }; - router.delete('/camera', camera.del); + app.fs.api.logAttr['DEL/camera/:cameraId'] = { content: '删除摄像头', visible: false }; + router.delete('/camera/:cameraId', camera.del); app.fs.api.logAttr['GET/camera/export'] = { content: '导出摄像头信息', visible: false }; router.get('/camera/export', camera.cameraExport); diff --git a/code/VideoAccess-VCMP/web/client/src/components/simpleFileDownButton.jsx b/code/VideoAccess-VCMP/web/client/src/components/simpleFileDownButton.jsx index 047594a..5ee4eee 100644 --- a/code/VideoAccess-VCMP/web/client/src/components/simpleFileDownButton.jsx +++ b/code/VideoAccess-VCMP/web/client/src/components/simpleFileDownButton.jsx @@ -23,7 +23,9 @@ const SimpleFileDownButton = (props) => { > 导出 - ); } diff --git a/code/VideoAccess-VCMP/web/client/src/sections/equipmentWarehouse/components/skeletonScreen.jsx b/code/VideoAccess-VCMP/web/client/src/sections/equipmentWarehouse/components/skeletonScreen.jsx index eb720fa..f0462ae 100644 --- a/code/VideoAccess-VCMP/web/client/src/sections/equipmentWarehouse/components/skeletonScreen.jsx +++ b/code/VideoAccess-VCMP/web/client/src/sections/equipmentWarehouse/components/skeletonScreen.jsx @@ -1,3 +1,4 @@ +import React, { useState, useEffect } from "react"; import { Table } from "@douyinfe/semi-ui"; export function skeletonScreen(line, columns) { diff --git a/code/VideoAccess-VCMP/web/webpack.config.js b/code/VideoAccess-VCMP/web/webpack.config.js index bb23307..7bba81f 100644 --- a/code/VideoAccess-VCMP/web/webpack.config.js +++ b/code/VideoAccess-VCMP/web/webpack.config.js @@ -32,7 +32,9 @@ module.exports = { }, plugins: [ new webpack.HotModuleReplacementPlugin(), - new BundleAnalyzerPlugin(), + new BundleAnalyzerPlugin({ + analyzerPort: 8000, + }), ], module: { rules: [{ From 63e8968c10d67d342d6e7de2eff90b73f35ed994 Mon Sep 17 00:00:00 2001 From: yuan_yi <1650192445@qq.com> Date: Thu, 2 Jun 2022 20:19:26 +0800 Subject: [PATCH 2/2] AUTH CROSS --- code/VideoAccess-VCMP/api/.vscode/launch.json | 1 + .../api/app/lib/controllers/camera/create.js | 1 + .../api/app/lib/controllers/nvr/index.js | 18 +- .../api/app/lib/service/paasRequest.js | 7 +- code/VideoAccess-VCMP/api/config.js | 8 +- .../src/layout/components/header/index.jsx | 144 ++++---- .../src/layout/containers/layout/index.jsx | 110 +++--- .../web/client/src/layout/index.jsx | 317 ++++++++++-------- .../client/src/sections/auth/actions/auth.js | 111 +++--- .../src/sections/auth/containers/login.jsx | 12 +- 10 files changed, 394 insertions(+), 335 deletions(-) diff --git a/code/VideoAccess-VCMP/api/.vscode/launch.json b/code/VideoAccess-VCMP/api/.vscode/launch.json index 9568af8..5b54c7b 100644 --- a/code/VideoAccess-VCMP/api/.vscode/launch.json +++ b/code/VideoAccess-VCMP/api/.vscode/launch.json @@ -20,6 +20,7 @@ "--redisPort 6379", "--axyApiUrl http://127.0.0.1:4100", "--iotAuthApi http://127.0.0.1:4200", + "--iotVideoServerUrl http://221.230.55.27:8081", "--godUrl https://restapi.amap.com/v3", "--godKey 21c2d970e1646bb9a795900dd00093ce" ] diff --git a/code/VideoAccess-VCMP/api/app/lib/controllers/camera/create.js b/code/VideoAccess-VCMP/api/app/lib/controllers/camera/create.js index 3af5b2e..cc74a2e 100644 --- a/code/VideoAccess-VCMP/api/app/lib/controllers/camera/create.js +++ b/code/VideoAccess-VCMP/api/app/lib/controllers/camera/create.js @@ -161,6 +161,7 @@ async function createNvrCamera (ctx) { }) } else { createData.push({ + type: 'nvr', serialNo: c.streamid, name: c.name, sip: corCamera.sipip, diff --git a/code/VideoAccess-VCMP/api/app/lib/controllers/nvr/index.js b/code/VideoAccess-VCMP/api/app/lib/controllers/nvr/index.js index 01d58a6..e96d72d 100644 --- a/code/VideoAccess-VCMP/api/app/lib/controllers/nvr/index.js +++ b/code/VideoAccess-VCMP/api/app/lib/controllers/nvr/index.js @@ -243,7 +243,20 @@ async function detail (ctx) { } const corUser = await ctx.app.fs.authRequest.get(`user/${nvrRes.createUserId}/message`, { query: { token } }) - + const serverDRes = (await ctx.app.fs.videoServerRequest.post(`gateway/plugins`) || '') + const serverDArr = JSON.parse(serverDRes.replace(/'/g, '"')) || [] + const serverDConfig = serverDArr.find(s => s.Name == 'GB28181') + let serveD = {} + if (serverDConfig) { + const { Config } = serverDConfig + let ConfigArr = Config.split('\n') + for (let c of ConfigArr) { + let config = c.split(' = ') + if (config.length == 2) { + serveD[config[0].trim()] = config[1].trim().replace(/\"/g, '') + } + } + } let nvrDetail = { ...nvrRes.dataValues, station: bindStations, @@ -251,7 +264,8 @@ async function detail (ctx) { createUser: { namePresent: corUser[0].namePresent }, - accessWay: 'GB/T28181' + accessWay: 'GB/T28181', + accessInfo: serveD } ctx.status = 200; diff --git a/code/VideoAccess-VCMP/api/app/lib/service/paasRequest.js b/code/VideoAccess-VCMP/api/app/lib/service/paasRequest.js index 5ab6678..1cfa081 100644 --- a/code/VideoAccess-VCMP/api/app/lib/service/paasRequest.js +++ b/code/VideoAccess-VCMP/api/app/lib/service/paasRequest.js @@ -2,9 +2,10 @@ const request = require('superagent') class paasRequest { - constructor(root, { query = {} } = {}) { + constructor(root, { query = {} } = {}, option) { this.root = root; this.query = query + this.option = option } #buildUrl = (url) => { @@ -16,7 +17,7 @@ class paasRequest { if (err) { reject(err); } else { - resolve(res.body); + resolve(res[this.option.dataWord]); } }; } @@ -51,7 +52,7 @@ function factory (app, opts) { try { for (let r of opts.pssaRequest) { if (r.name && r.root) { - app.fs[r.name] = new paasRequest(r.root, { ...(r.params || {}) }) + app.fs[r.name] = new paasRequest(r.root, { ...(r.params || {}) }, { dataWord: r.dataWord || 'body' }) } else { throw 'opts.pssaRequest 参数错误!' } diff --git a/code/VideoAccess-VCMP/api/config.js b/code/VideoAccess-VCMP/api/config.js index dd70cf4..4b88f2b 100644 --- a/code/VideoAccess-VCMP/api/config.js +++ b/code/VideoAccess-VCMP/api/config.js @@ -14,8 +14,9 @@ args.option(['f', 'fileHost'], '文件中心本地化存储: WebApi 服务器地 args.option('redisHost', 'redisHost'); args.option('redisPort', 'redisPort'); args.option('redisPswd', 'redisPassword'); -args.option('iotAuthApi', 'IOT 鉴权 api'); args.option('axyApiUrl', '安心云 api'); +args.option('iotAuthApi', 'IOT 鉴权 api'); +args.option('iotVideoServerUrl', '视频后端服务地址'); args.option('godUrl', '高德地图API请求地址'); args.option('godKey', '高德地图API key'); @@ -29,6 +30,7 @@ const IOTA_REDIS_SERVER_PORT = process.env.IOTA_REDIS_SERVER_PORT || flags.redis const IOTA_REDIS_SERVER_PWD = process.env.IOTA_REDIS_SERVER_PWD || flags.redisPswd || "";//redis 密码 const IOT_AUTH_API = process.env.IOT_AUTH_API || flags.iotAuthApi; +const IOT_VIDEO_SERVER_URL = process.env.IOT_VIDEO_SERVER_URL || flags.iotVideoServerUrl const AXY_API_URL = process.env.AXY_API_URL || flags.axyApiUrl; const GOD_URL = process.env.GOD_URL || flags.godUrl || 'https://restapi.amap.com/v3'; const GOD_KEY = process.env.GOD_KEY || flags.godKey; @@ -85,6 +87,10 @@ const product = { key: GOD_KEY } } + }, { + name: 'videoServerRequest', + root: IOT_VIDEO_SERVER_URL + '/api', + dataWord: 'text' },] } } diff --git a/code/VideoAccess-VCMP/web/client/src/layout/components/header/index.jsx b/code/VideoAccess-VCMP/web/client/src/layout/components/header/index.jsx index 684980d..5d8ee4d 100644 --- a/code/VideoAccess-VCMP/web/client/src/layout/components/header/index.jsx +++ b/code/VideoAccess-VCMP/web/client/src/layout/components/header/index.jsx @@ -4,82 +4,84 @@ import { connect } from "react-redux"; import { Nav, Avatar, Dropdown } from "@douyinfe/semi-ui"; const Header = (props) => { - const { dispatch, history, user, actions, socket } = props; + const { dispatch, history, user, actions, socket } = props; - return ( - <> -