From c4e4936231f1f31bd6f5db067a34f0dd0ff59854 Mon Sep 17 00:00:00 2001 From: wenlele Date: Mon, 18 Dec 2023 15:28:59 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E7=9B=91=E6=B5=8B=E4=B8=8B?= =?UTF-8?q?=E8=BD=BD=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lib/controllers/alarm/dataContinuity.js | 6 +- api/app/lib/models/alarm_data_continuity.js | 103 ++++++++++-------- .../schema/1.update_alarm_data_continuity.sql | 5 + .../sections/data/containers/dataQuery.jsx | 27 +++-- 4 files changed, 81 insertions(+), 60 deletions(-) create mode 100644 script/4.1/schema/1.update_alarm_data_continuity.sql diff --git a/api/app/lib/controllers/alarm/dataContinuity.js b/api/app/lib/controllers/alarm/dataContinuity.js index 3cbda06..335c6bf 100644 --- a/api/app/lib/controllers/alarm/dataContinuity.js +++ b/api/app/lib/controllers/alarm/dataContinuity.js @@ -9,7 +9,7 @@ async function postDataContinuity (ctx) { try { const { utils: { sendAppearToWeb }, clickHouse } = ctx.app.fs const models = ctx.fs.dc.models; - const { type, file, } = ctx.request.body + const { type, file, fileUrl } = ctx.request.body const now = moment().format() if (!type) { @@ -24,7 +24,7 @@ async function postDataContinuity (ctx) { } await models.AlarmDataContinuity.create({ - type, file, createTime: now + type, file, createTime: now, fileUrl }); ctx.status = 204; @@ -183,7 +183,7 @@ async function dataContinuityList (ctx) { let findOption = { order: [['createTime', 'desc']], where: {}, - attributes: ['id', 'type', 'createTime'], + attributes: ['id', 'type', 'createTime', 'fileUrl'], } if (limit) { diff --git a/api/app/lib/models/alarm_data_continuity.js b/api/app/lib/models/alarm_data_continuity.js index 483492f..be25068 100644 --- a/api/app/lib/models/alarm_data_continuity.js +++ b/api/app/lib/models/alarm_data_continuity.js @@ -2,51 +2,60 @@ 'use strict'; module.exports = dc => { - const DataTypes = dc.ORM; - const sequelize = dc.orm; - const AlarmDataContinuity = sequelize.define("alarmDataContinuity", { - id: { - type: DataTypes.INTEGER, - allowNull: false, - defaultValue: null, - comment: null, - primaryKey: true, - field: "id", - autoIncrement: true, - unique: "alarm_data_continuity_id_uindex" - }, - file: { - type: DataTypes.TEXT, - allowNull: false, - defaultValue: null, - comment: null, - primaryKey: false, - field: "file", - autoIncrement: false - }, - type: { - type: DataTypes.INTEGER, - allowNull: false, - defaultValue: null, - comment: null, - primaryKey: false, - field: "type", - autoIncrement: false - }, - createTime: { - type: DataTypes.DATE, - allowNull: false, - defaultValue: null, - comment: null, - primaryKey: false, - field: "create_time", - autoIncrement: false - }, - }, { - tableName: "alarm_data_continuity", - comment: "", - indexes: [] - }); - dc.models.AlarmDataContinuity = AlarmDataContinuity; - return AlarmDataContinuity; + const DataTypes = dc.ORM; + const sequelize = dc.orm; + const AlarmDataContinuity = sequelize.define("alarmDataContinuity", { + id: { + type: DataTypes.INTEGER, + allowNull: false, + defaultValue: null, + comment: null, + primaryKey: true, + field: "id", + autoIncrement: true, + unique: "alarm_data_continuity_id_uindex" + }, + file: { + type: DataTypes.TEXT, + allowNull: false, + defaultValue: null, + comment: null, + primaryKey: false, + field: "file", + autoIncrement: false + }, + type: { + type: DataTypes.INTEGER, + allowNull: false, + defaultValue: null, + comment: null, + primaryKey: false, + field: "type", + autoIncrement: false + }, + createTime: { + type: DataTypes.DATE, + allowNull: false, + defaultValue: null, + comment: null, + primaryKey: false, + field: "create_time", + autoIncrement: false + }, + fileUrl: { + type: DataTypes.STRING, + allowNull: true, + defaultValue: null, + comment: null, + primaryKey: false, + field: "file_url", + autoIncrement: false + }, + }, { + tableName: "alarm_data_continuity", + comment: "", + indexes: [] + }); + dc.models.AlarmDataContinuity = AlarmDataContinuity; + return AlarmDataContinuity; }; \ No newline at end of file diff --git a/script/4.1/schema/1.update_alarm_data_continuity.sql b/script/4.1/schema/1.update_alarm_data_continuity.sql new file mode 100644 index 0000000..9ddc759 --- /dev/null +++ b/script/4.1/schema/1.update_alarm_data_continuity.sql @@ -0,0 +1,5 @@ +alter table alarm_data_continuity + add file_url varchar; + +comment on column alarm_data_continuity.file_url is '文件地址'; + diff --git a/web/client/src/sections/data/containers/dataQuery.jsx b/web/client/src/sections/data/containers/dataQuery.jsx index 0114193..16fa60d 100644 --- a/web/client/src/sections/data/containers/dataQuery.jsx +++ b/web/client/src/sections/data/containers/dataQuery.jsx @@ -121,18 +121,25 @@ const DataQuery = (props) => { title: '操作', dataIndex: 'option', render: (text, record, index) => { + return ( - + { + record?.fileUrl ? + : + } +