diff --git a/api/app/lib/controllers/alarm/app.js b/api/app/lib/controllers/alarm/app.js index e970300..7d3f599 100644 --- a/api/app/lib/controllers/alarm/app.js +++ b/api/app/lib/controllers/alarm/app.js @@ -58,7 +58,7 @@ async function notedInspection (ctx) { async function apiError (ctx) { try { const models = ctx.fs.dc.models; - const { projectAppId, alarmContent, router, statusCode } = ctx.request.body + const { projectAppId, alarmContent, router, statusCode, screenshot = '' } = ctx.request.body const now = moment().format() let storageData = { @@ -86,6 +86,7 @@ async function apiError (ctx) { }) storageData.serialNumber = 'WEB' + (existCount < 9 ? '0' + (existCount + 1) : existCount) storageData.createTime = now + storageData.screenshot = screenshot await models.AppAlarm.create(storageData) } diff --git a/api/app/lib/controllers/organization/index.js b/api/app/lib/controllers/organization/index.js index 358843c..67c4b87 100644 --- a/api/app/lib/controllers/organization/index.js +++ b/api/app/lib/controllers/organization/index.js @@ -48,11 +48,15 @@ async function editUser (ctx) { // 存在且传递id 或者 不传id也存在 // 修改 update storageData.deleted = false - storageData.role = role if ( - storageData.role.includes('admin') + role.includes('admin') ) { + // 正在修改为管理员 storageData.disabled = true + storageData.role = [...[existUserRes.role], ...role] + } else if (existUserRes.role.includes('admin')) { + // 正在修改成员 但是此时还是管理员 + storageData.role = [...role, 'admin'] } await models.User.update(storageData, { where: { @@ -64,7 +68,7 @@ async function editUser (ctx) { await models.User.create(storageData) } - ctx.status = 200 + ctx.status = 204 } catch (error) { ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); ctx.status = 400; diff --git a/api/app/lib/models/app_alarm.js b/api/app/lib/models/app_alarm.js index 6d6bdbb..fb958c7 100644 --- a/api/app/lib/models/app_alarm.js +++ b/api/app/lib/models/app_alarm.js @@ -31,7 +31,11 @@ module.exports = dc => { comment: "对应的项目id", primaryKey: false, field: "project_app_id", - autoIncrement: false + autoIncrement: false, + references: { + key: "id", + model: "projectApp" + } }, appDomain: { type: DataTypes.STRING, @@ -95,6 +99,15 @@ module.exports = dc => { primaryKey: false, field: "status_code", autoIncrement: false + }, + screenshot: { + type: DataTypes.STRING, + allowNull: true, + defaultValue: null, + comment: null, + primaryKey: false, + field: "screenshot", + autoIncrement: false } }, { tableName: "app_alarm", diff --git a/api/sequelize-automate.config.js b/api/sequelize-automate.config.js index ae7d5c4..e34d53b 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_inspection'], // 指定生成哪些表的 models,如 ['user', 'user_post'];如果为 null,则忽略改属性 + tables: ['app_alarm'], // 指定生成哪些表的 models,如 ['user', 'user_post'];如果为 null,则忽略改属性 skipTables: [], // 指定跳过哪些表的 models,如 ['user'];如果为 null,则忽略改属性 tsNoCheck: false, // 是否添加 `@ts-nocheck` 注释到 models 文件中 ignorePrefix: [], // 生成的模型名称忽略的前缀,因为 项目中有以下表名是以 t_ 开头的,在实际模型中不需要, 可以添加多个 [ 't_data_', 't_',] ,长度较长的 前缀放前面 diff --git a/script/0.0.3/1.alert_app_alarm.sql b/script/0.0.3/1.alert_app_alarm.sql new file mode 100644 index 0000000..0bee93d --- /dev/null +++ b/script/0.0.3/1.alert_app_alarm.sql @@ -0,0 +1,2 @@ +alter table app_alarm + add screenshot varchar(1024); \ No newline at end of file