From 6b86b354097b055332d6bafcbbaff180082173c2 Mon Sep 17 00:00:00 2001 From: "gao.zhiyuan" Date: Fri, 9 Sep 2022 16:57:38 +0800 Subject: [PATCH] =?UTF-8?q?app=20=E6=88=AA=E5=9B=BE=E4=B8=8A=E4=BC=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/app/lib/controllers/alarm/app.js | 6 +++--- api/app/lib/models/app_inspection.js | 8 ++++---- api/sequelize-automate.config.js | 2 +- script/1.0.0/3.update_tables.sql | 2 ++ 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/api/app/lib/controllers/alarm/app.js b/api/app/lib/controllers/alarm/app.js index daa2bcb..62ec012 100644 --- a/api/app/lib/controllers/alarm/app.js +++ b/api/app/lib/controllers/alarm/app.js @@ -5,15 +5,15 @@ const moment = require('moment') async function inspection (ctx) { try { const models = ctx.fs.dc.models; - const { projectAppId, screenshot = [], description } = ctx.request.body + const { projectAppId, screenshot = [], } = ctx.request.body const now = moment().format() const storageData = screenshot.map(s => { return { projectAppId, - screenshot: [s], + screenshot: s.url, createTime: now, - description, + description: s.description, } }) diff --git a/api/app/lib/models/app_inspection.js b/api/app/lib/models/app_inspection.js index 064ea38..cb48dab 100644 --- a/api/app/lib/models/app_inspection.js +++ b/api/app/lib/models/app_inspection.js @@ -38,8 +38,8 @@ module.exports = dc => { autoIncrement: false }, screenshot: { - type: DataTypes.ARRAY(DataTypes.STRING), - allowNull: true, + type: DataTypes.STRING, + allowNull: false, defaultValue: null, comment: "截图存储路径", primaryKey: false, @@ -68,11 +68,11 @@ module.exports = dc => { type: DataTypes.STRING, allowNull: true, defaultValue: null, - comment: "", + comment: null, primaryKey: false, field: "description", autoIncrement: false - }, + } }, { tableName: "app_inspection", comment: "", diff --git a/api/sequelize-automate.config.js b/api/sequelize-automate.config.js index e34d53b..ae7d5c4 100644 --- a/api/sequelize-automate.config.js +++ b/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_alarm'], // 指定生成哪些表的 models,如 ['user', 'user_post'];如果为 null,则忽略改属性 + tables: ['app_inspection'], // 指定生成哪些表的 models,如 ['user', 'user_post'];如果为 null,则忽略改属性 skipTables: [], // 指定跳过哪些表的 models,如 ['user'];如果为 null,则忽略改属性 tsNoCheck: false, // 是否添加 `@ts-nocheck` 注释到 models 文件中 ignorePrefix: [], // 生成的模型名称忽略的前缀,因为 项目中有以下表名是以 t_ 开头的,在实际模型中不需要, 可以添加多个 [ 't_data_', 't_',] ,长度较长的 前缀放前面 diff --git a/script/1.0.0/3.update_tables.sql b/script/1.0.0/3.update_tables.sql index ee8df65..5848162 100644 --- a/script/1.0.0/3.update_tables.sql +++ b/script/1.0.0/3.update_tables.sql @@ -1,2 +1,4 @@ alter table app_inspection add description varchar(1024); + +alter table app_inspection alter column screenshot type varchar(1024) using screenshot::varchar(1024); \ No newline at end of file