Browse Source

视频告警返回项企项目信息

dev
巴林闲侠 2 years ago
parent
commit
15541b4fe1
  1. 4
      api/.vscode/launch.json
  2. 11
      api/app/lib/controllers/alarm/video.js
  3. 102
      api/app/lib/controllers/console/toolLink.js
  4. 9
      api/app/lib/models/quick_link.js
  5. 14
      api/app/lib/routes/console/index.js
  6. 2
      api/sequelize-automate.config.js
  7. 17
      script/0.0.4 copy/schema/1.alert_table.sql

4
api/.vscode/launch.json

@ -16,9 +16,9 @@
"-p 4600",
"-f http://localhost:4600",
//
"-g postgres://postgres:123@10.8.30.32:5432/orational_service",
// "-g postgres://postgres:123@10.8.30.32:5432/orational_service",
//
// "-g postgres://FashionAdmin:123456@10.8.30.156:5432/POMS",
"-g postgres://FashionAdmin:123456@10.8.30.156:5432/POMS",
"-k node35:6667,node36:6667,node37:6667",
"--iotaProxy http://10.8.30.157:17007",
"--redisHost 10.8.30.112",

11
api/app/lib/controllers/alarm/video.js

@ -214,6 +214,17 @@ async function alarmList (ctx) {
struc: [],
station: []
}
// pep 项目
d.pomsProject = (
anxinStruc.find(as => as.strucId == a.strucId) ||
{
pomsProject: [
]
}
).pomsProject
if (a.resolveId) {
d.resolve.push({
id: a.resolveId,

102
api/app/lib/controllers/console/toolLink.js

@ -1,10 +1,106 @@
'use strict';
async function add (ctx) {
async function list (ctx) {
try {
const { models } = ctx.fs.dc;
const { userId, pepUserId } = ctx.fs.api
const linkListRes = await models.QuickLink.findAll({
attributes: { exclude: ['userId'] },
where: {
userId,
}
})
ctx.status = 20;
ctx.status = 200;
ctx.body = linkListRes
} catch (error) {
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`);
ctx.status = 400;
ctx.body = {
message: typeof error == 'string' ? error : undefined
}
}
}
async function edit (ctx) {
try {
const { models } = ctx.fs.dc;
const { userId, pepUserId } = ctx.fs.api
const { linkId, name, link } = ctx.request.body
if (!name || !link) {
throw '请将参数填写完整'
}
let findOption = {
where: {
userId: userId,
$or: [{
name,
}, {
link,
}]
}
}
if (linkId) {
findOption.where.id = { $ne: linkId }
}
const existRes = await models.QuickLink.findOne({
where: {
userId: userId,
$or: [{
name,
}, {
link,
}]
}
})
if (existRes) {
throw '已有相同名称/地址的工具'
}
if (linkId) {
await models.QuickLink.update({
name,
link,
}, {
where: {
id: linkId
}
})
} else {
await models.QuickLink.create({
userId,
name,
link,
})
}
ctx.status = 204;
} catch (error) {
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`);
ctx.status = 400;
ctx.body = {
message: typeof error == 'string' ? error : undefined
}
}
}
async function del (ctx) {
try {
const { models } = ctx.fs.dc;
const { userId, pepUserId } = ctx.fs.api
const { linkId } = ctx.params
await models.QuickLink.destroy({
where: {
id: linkId,
userId,
}
})
ctx.status = 204;
} catch (error) {
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`);
ctx.status = 400;
@ -15,5 +111,5 @@ async function add (ctx) {
}
module.exports = {
add
list, edit, del,
};

9
api/app/lib/models/quick_link.js

@ -36,6 +36,15 @@ module.exports = dc => {
primaryKey: false,
field: "link",
autoIncrement: false
},
name: {
type: DataTypes.STRING,
allowNull: false,
defaultValue: null,
comment: null,
primaryKey: false,
field: "name",
autoIncrement: false
}
}, {
tableName: "quick_link",

14
api/app/lib/routes/console/index.js

@ -0,0 +1,14 @@
'use strict';
const toolLink = require('../../controllers/console/toolLink');
module.exports = function (app, router, opts) {
app.fs.api.logAttr['GET/console/toollink'] = { content: '获取常用工具', visible: true };
router.get('/console/toollink', toolLink.list);
app.fs.api.logAttr['PUT/console/toollink'] = { content: '编辑常用工具', visible: true };
router.put('/console/toollink', toolLink.edit);
app.fs.api.logAttr['DEL/console/toollink'] = { content: '删除常用工具', visible: true };
router.del('/console/toollink/:linkId', toolLink.del);
};

2
api/sequelize-automate.config.js

@ -26,7 +26,7 @@ module.exports = {
dir: './app/lib/models', // 指定输出 models 文件的目录
typesDir: 'models', // 指定输出 TypeScript 类型定义的文件目录,只有 TypeScript / Midway 等会有类型定义
emptyDir: false, // !!! 谨慎操作 生成 models 之前是否清空 `dir` 以及 `typesDir`
tables: ['app_inspection'], // 指定生成哪些表的 models,如 ['user', 'user_post'];如果为 null,则忽略改属性
tables: ['quick_link'], // 指定生成哪些表的 models,如 ['user', 'user_post'];如果为 null,则忽略改属性
skipTables: [], // 指定跳过哪些表的 models,如 ['user'];如果为 null,则忽略改属性
tsNoCheck: false, // 是否添加 `@ts-nocheck` 注释到 models 文件中
ignorePrefix: [], // 生成的模型名称忽略的前缀,因为 项目中有以下表名是以 t_ 开头的,在实际模型中不需要, 可以添加多个 [ 't_data_', 't_',] ,长度较长的 前缀放前面

17
script/0.0.4 copy/schema/1.alert_table.sql

@ -0,0 +1,17 @@
create table if not exists quick_link
(
id serial not null,
user_id integer not null,
link varchar(256) not null,
name varchar(32) not null,
constraint quick_link_pk
primary key (id),
constraint quick_link_user_id_fk
foreign key (user_id) references "user"
);
comment on table quick_link is '对应我的常用工具功能';
create unique index if not exists quick_link_id_uindex
on quick_link (id);
Loading…
Cancel
Save