From 81f0a72620d4760d5e677428d56681dd36334f70 Mon Sep 17 00:00:00 2001 From: "gao.zhiyuan" Date: Fri, 16 Sep 2022 17:06:47 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BA=BA=E5=91=98=E6=B7=BB=E5=8A=A0=E5=88=A4?= =?UTF-8?q?=E9=87=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/app/lib/controllers/organization/index.js | 9 ++++++++- api/app/lib/controllers/project/bind.js | 10 ++++++++++ script/0.0.3/2.alter table project_correlation.sql | 4 ---- script/0.0.3/2.alter_table_project_correlation.sql | 7 +++++++ 4 files changed, 25 insertions(+), 5 deletions(-) delete mode 100644 script/0.0.3/2.alter table project_correlation.sql create mode 100644 script/0.0.3/2.alter_table_project_correlation.sql diff --git a/api/app/lib/controllers/organization/index.js b/api/app/lib/controllers/organization/index.js index 87c22c2..334ed1a 100644 --- a/api/app/lib/controllers/organization/index.js +++ b/api/app/lib/controllers/organization/index.js @@ -36,7 +36,14 @@ async function editUser (ctx) { pepUserId } }) - if (existUserRes && !existUserRes.deleted && !pomsUserId) { + if ( + existUserRes && !existUserRes.deleted && !pomsUserId && + ( + (existUserRes.role.includes('admin') && role.includes('admin')) + || (!existUserRes.role.includes('admin') && !role.includes('admin')) + // 都有或都没有管理员 + ) + ) { // 新增已存在未删除 throw '人员账号已添加' } diff --git a/api/app/lib/controllers/project/bind.js b/api/app/lib/controllers/project/bind.js index 58b1c8f..ffd21e1 100644 --- a/api/app/lib/controllers/project/bind.js +++ b/api/app/lib/controllers/project/bind.js @@ -6,8 +6,18 @@ async function bindAnxin2pep (ctx) { const { clickHouse } = ctx.app.fs const { bindId, name, pepProjectId, anxinProjectId = [], app = [] } = ctx.request.body + const existRes = await models.ProjectCorrelation.findOne({ + where: { + pepProjectId: pepProjectId + } + }) + if (bindId) { + } else { + if (existRes) { + throw '当前项企项目已绑定' + } } ctx.status = 20; diff --git a/script/0.0.3/2.alter table project_correlation.sql b/script/0.0.3/2.alter table project_correlation.sql deleted file mode 100644 index f6cb8b9..0000000 --- a/script/0.0.3/2.alter table project_correlation.sql +++ /dev/null @@ -1,4 +0,0 @@ -alter table project_correlation drop column pep_project_id; - -alter table project_correlation - add pep_project_id int not null; \ No newline at end of file diff --git a/script/0.0.3/2.alter_table_project_correlation.sql b/script/0.0.3/2.alter_table_project_correlation.sql new file mode 100644 index 0000000..57e37f7 --- /dev/null +++ b/script/0.0.3/2.alter_table_project_correlation.sql @@ -0,0 +1,7 @@ +alter table project_correlation drop column pep_project_id; + +alter table project_correlation + add pep_project_id int not null; + +alter table project_correlation + add del bool default false;