From 89a5d9a28a81f928f76d3dec150226e2d303b191 Mon Sep 17 00:00:00 2001 From: "gao.zhiyuan" Date: Tue, 20 Sep 2022 20:40:57 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4=E7=BB=91=E5=AE=9A=E5=85=B3?= =?UTF-8?q?=E7=B3=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/app/lib/controllers/project/bind.js | 5 +++-- api/app/lib/controllers/project/index.js | 1 + api/app/lib/models/project_correlation.js | 11 ++++++++++- script/0.0.3/2.alter_table_project_correlation.sql | 5 ++++- 4 files changed, 18 insertions(+), 4 deletions(-) diff --git a/api/app/lib/controllers/project/bind.js b/api/app/lib/controllers/project/bind.js index 9b5ac1b..f78b7f3 100644 --- a/api/app/lib/controllers/project/bind.js +++ b/api/app/lib/controllers/project/bind.js @@ -59,6 +59,7 @@ async function bindAnxin2pep (ctx) { let storageData = { name, pepProjectId, anxinProjectId, + updateTime: now, del: false, } @@ -129,7 +130,7 @@ async function bindAnxin2pep (ctx) { async function del (ctx) { try { const models = ctx.fs.dc.models; - const { bindId } = ctx.query + const { bindId } = ctx.params await models.ProjectCorrelation.update({ del: true @@ -139,7 +140,7 @@ async function del (ctx) { } }) - ctx.status = 20; + ctx.status = 204; } catch (error) { ctx.fs.logger.error(`path: ${ctx.path}, error: error`); ctx.status = 400; diff --git a/api/app/lib/controllers/project/index.js b/api/app/lib/controllers/project/index.js index 0d3be44..247f544 100644 --- a/api/app/lib/controllers/project/index.js +++ b/api/app/lib/controllers/project/index.js @@ -29,6 +29,7 @@ async function pomsProject (ctx) { where: { del: false }, + order: [['updateTime', 'desc']], distinct: true, include: { model: models.App, diff --git a/api/app/lib/models/project_correlation.js b/api/app/lib/models/project_correlation.js index 0996bb7..b0ae1be 100644 --- a/api/app/lib/models/project_correlation.js +++ b/api/app/lib/models/project_correlation.js @@ -68,7 +68,16 @@ module.exports = dc => { primaryKey: false, field: "del", autoIncrement: false - } + }, + updateTime: { + type: DataTypes.DATE, + allowNull: false, + defaultValue: null, + comment: null, + primaryKey: false, + field: "update_time", + autoIncrement: false + }, }, { tableName: "project_correlation", comment: "", diff --git a/script/0.0.3/2.alter_table_project_correlation.sql b/script/0.0.3/2.alter_table_project_correlation.sql index a6f9088..5df88da 100644 --- a/script/0.0.3/2.alter_table_project_correlation.sql +++ b/script/0.0.3/2.alter_table_project_correlation.sql @@ -6,4 +6,7 @@ alter table project_correlation alter table project_correlation add del bool default false; -alter table project_correlation alter column pep_project_id drop not null; \ No newline at end of file +alter table project_correlation alter column pep_project_id drop not null; + +alter table project_correlation + add update_time timestamp with time zone; \ No newline at end of file