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;