From 9794a829d53ad584ace6957466092618064873f9 Mon Sep 17 00:00:00 2001 From: "gao.zhiyuan" Date: Wed, 14 Sep 2022 13:44:51 +0800 Subject: [PATCH] clickhouse params --- api/.vscode/launch.json | 5 +-- api/app/lib/controllers/organization/index.js | 17 ++++++++-- api/config.js | 32 ++++++++++--------- 3 files changed, 34 insertions(+), 20 deletions(-) diff --git a/api/.vscode/launch.json b/api/.vscode/launch.json index ee22b5e..8903b20 100644 --- a/api/.vscode/launch.json +++ b/api/.vscode/launch.json @@ -31,8 +31,9 @@ "--clickHouseUrl http://10.8.30.71", "--clickHousePort 30123", "--clickHouseAnxincloud anxinyun", - "--clickHousePepEmis ssanxinyun1", - "--clickHouseProjectManage anxinyun2", + "--clickHousePepEmis pepca", + "--clickHouseProjectManage peppm", + "--clickHouseVcmp video_accrss1", ] }, { diff --git a/api/app/lib/controllers/organization/index.js b/api/app/lib/controllers/organization/index.js index 44b1191..9284f47 100644 --- a/api/app/lib/controllers/organization/index.js +++ b/api/app/lib/controllers/organization/index.js @@ -44,10 +44,10 @@ async function editUser (ctx) { // 存在且传递id 或者 不传id也存在 // 修改 update storageData.deleted = false + storageData.role = [...new Set([...existUserRes.role, ...role])] if ( - role.includes('admin') + storageData.role.includes('admin') ) { - storageData.role = [...new Set([...existUserRes.role, ...role])] storageData.disabled = false } await models.User.update(storageData, { @@ -75,6 +75,16 @@ async function putUser (ctx) { const models = ctx.fs.dc.models; const { pomsUserId } = ctx.params const { disabled = undefined, deleted = undefined } = ctx.request.body + const existUserRes = await models.User.findOne({ + where: { + id: pomsUserId + } + }) + + if (existUserRes && existUserRes.role.includes('admin')) { + throw '已是管理员,请先解除管理员权限' + } + const updateData = { disabled, deleted, @@ -84,6 +94,7 @@ async function putUser (ctx) { delete updateData[k] } } + await models.User.update(updateData, { where: { id: pomsUserId @@ -94,7 +105,7 @@ async function putUser (ctx) { ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); ctx.status = 400; ctx.body = { - + message: typeof error == 'string' ? error : undefined } } } diff --git a/api/config.js b/api/config.js index 47ebc35..b7e9b02 100644 --- a/api/config.js +++ b/api/config.js @@ -73,20 +73,14 @@ const CLICKHOUST_PEP_EMIS = process.env.CLICKHOUST_PEP_EMIS || flags.clickHouseP const CLICKHOUST_PROJECT_MANAGE = process.env.CLICKHOUST_PROJECT_MANAGE || flags.clickHouseProjectManage if ( - !POMS_DB || - !IOTA_REDIS_SERVER_HOST || !IOTA_REDIS_SERVER_PORT || - !GOD_KEY || - !API_ANXINYUN_URL || - !API_EMIS_URL || - !QINIU_DOMAIN_QNDMN_RESOURCE || !QINIU_BUCKET_RESOURCE || !QINIU_AK || !QINIU_SK - || - !CLICKHOUST_URL - || - !CLICKHOUST_PORT || - !CLICKHOUST_ANXINCLOUD || - !CLICKHOUST_PEP_EMIS - || - !CLICKHOUST_PROJECT_MANAGE + !POMS_DB + || !IOTA_REDIS_SERVER_HOST || !IOTA_REDIS_SERVER_PORT + || !GOD_KEY + || !API_ANXINYUN_URL + || !API_EMIS_URL + || !QINIU_DOMAIN_QNDMN_RESOURCE || !QINIU_BUCKET_RESOURCE || !QINIU_AK || !QINIU_SK + || !CLICKHOUST_URL || !CLICKHOUST_PORT + || !CLICKHOUST_ANXINCLOUD || !CLICKHOUST_PEP_EMIS || !CLICKHOUST_PROJECT_MANAGE ) { console.log('缺少启动参数,异常退出'); args.showHelp(); @@ -154,7 +148,15 @@ const product = { key: GOD_KEY } } - },] + },], + clickHouse: { + url: CLICKHOUST_URL, + port: CLICKHOUST_PORT, + db:[{ + name:'', + db:'' + }] + } } } ],