diff --git a/api/.vscode/launch.json b/api/.vscode/launch.json index 8903b20..7bac2dd 100644 --- a/api/.vscode/launch.json +++ b/api/.vscode/launch.json @@ -29,6 +29,7 @@ // "--qndmn http://resources.anxinyun.cn", "--qndmn http://rhvqdivo5.hn-bkt.clouddn.com", "--clickHouseUrl http://10.8.30.71", + // "--clickHouseUrl https://clickhouse01.anxinyun.cn/play", "--clickHousePort 30123", "--clickHouseAnxincloud anxinyun", "--clickHousePepEmis pepca", diff --git a/api/app/lib/controllers/alarm/app.js b/api/app/lib/controllers/alarm/app.js index 58fe6e8..3313e79 100644 --- a/api/app/lib/controllers/alarm/app.js +++ b/api/app/lib/controllers/alarm/app.js @@ -89,7 +89,7 @@ async function inspectionList (ctx) { ctx.status = 200; ctx.body = inspectionRes } catch (error) { - ctx.fs.logger.error(`path: ${ctx.path}, error: error`); + ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); ctx.status = 400; ctx.body = { message: typeof error == 'string' ? error : undefined @@ -114,7 +114,7 @@ async function notedInspection (ctx) { ctx.status = 204; } catch (error) { - ctx.fs.logger.error(`path: ${ctx.path}, error: error`); + ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); ctx.status = 400; ctx.body = { message: typeof error == 'string' ? error : undefined @@ -159,7 +159,7 @@ async function apiError (ctx) { ctx.status = 200; } catch (error) { - ctx.fs.logger.error(`path: ${ctx.path}, error: error`); + ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); ctx.status = 400; ctx.body = { message: typeof error == 'string' ? error : undefined @@ -176,7 +176,7 @@ async function apiErrorList (ctx) { ctx.status = 200; ctx.body = [] } catch (error) { - ctx.fs.logger.error(`path: ${ctx.path}, error: error`); + ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); ctx.status = 400; ctx.body = { message: typeof error == 'string' ? error : undefined @@ -199,7 +199,7 @@ async function confirmApiError (ctx) { ctx.status = 204; } catch (error) { - ctx.fs.logger.error(`path: ${ctx.path}, error: error`); + ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); ctx.status = 400; ctx.body = { message: typeof error == 'string' ? error : undefined diff --git a/api/app/lib/controllers/auth/index.js b/api/app/lib/controllers/auth/index.js index d038b79..bd67e02 100644 --- a/api/app/lib/controllers/auth/index.js +++ b/api/app/lib/controllers/auth/index.js @@ -29,7 +29,7 @@ async function login (ctx, next) { if (!pomsRegisterRes) { throw '你还不是飞尚运维中台成员,请联系管理员添加权限' } else if ( - pomsRegisterRes.disable && (!pomsRegisterRes.role || !pomsRegisterRes.role.includes('admin')) + pomsRegisterRes.disabled && !pomsRegisterRes.role.includes('admin') ) { throw '当前账号已禁用' } diff --git a/api/app/lib/controllers/organization/index.js b/api/app/lib/controllers/organization/index.js index f8c4ba7..87c22c2 100644 --- a/api/app/lib/controllers/organization/index.js +++ b/api/app/lib/controllers/organization/index.js @@ -5,13 +5,16 @@ async function allDeps (ctx) { try { const models = ctx.fs.dc.models; const { redis } = ctx.app - + const start = moment() let depRes = await redis.get('allDepartments') + console.log(`DurationCalc: 1 用时 ${moment().diff(start, 'milliseconds')}`); if (depRes) { depRes = JSON.parse(depRes) + console.log(`DurationCalc: 2 用时 ${moment().diff(start, 'milliseconds')}`); depRes = depRes.departments + console.log(`DurationCalc: 3 用时 ${moment().diff(start, 'milliseconds')}`); } - + console.log(`DurationCalc: 4 用时 ${moment().diff(start, 'milliseconds')}`); ctx.status = 200; ctx.body = depRes || [] } catch (error) { @@ -26,14 +29,14 @@ async function allDeps (ctx) { async function editUser (ctx) { try { const models = ctx.fs.dc.models; - const { pepUserId, role = [], correlationProject = [] } = ctx.request.body + const { pomsUserId, pepUserId, role = [], correlationProject = [] } = ctx.request.body const existUserRes = await models.User.findOne({ where: { pepUserId } }) - if (existUserRes && !existUserRes.deleted && !pepUserId) { + if (existUserRes && !existUserRes.deleted && !pomsUserId) { // 新增已存在未删除 throw '人员账号已添加' } @@ -77,7 +80,7 @@ async function editUser (ctx) { ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); ctx.status = 400; ctx.body = { - + message: typeof error == 'string' ? error : undefined } } } @@ -93,7 +96,7 @@ async function putUser (ctx) { } }) - if (existUserRes && existUserRes.role.includes('admin') && !disabled) { + if (existUserRes && existUserRes.role.includes('admin') && disabled == false) { throw '成员不能既是管理员又是普通成员' } @@ -147,7 +150,7 @@ async function delAdmin (ctx) { ctx.status = 204; } catch (error) { - ctx.fs.logger.error(`path: ${ctx.path}, error: error`); + ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); ctx.status = 400; ctx.body = { message: typeof error == 'string' ? error : undefined diff --git a/api/app/lib/controllers/project/bind.js b/api/app/lib/controllers/project/bind.js index f11651e..f6a4bbd 100644 --- a/api/app/lib/controllers/project/bind.js +++ b/api/app/lib/controllers/project/bind.js @@ -9,7 +9,7 @@ async function bindAnxin2pep (ctx) { ctx.status = 20; } catch (error) { - ctx.fs.logger.error(`path: ${ctx.path}, error: error`); + ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); ctx.status = 400; ctx.body = { message: typeof error == 'string' ? error : undefined diff --git a/api/app/lib/controllers/project/index.js b/api/app/lib/controllers/project/index.js index 70af536..85062af 100644 --- a/api/app/lib/controllers/project/index.js +++ b/api/app/lib/controllers/project/index.js @@ -12,7 +12,7 @@ async function appList (ctx) { ctx.status = 200; ctx.body = appRes } catch (error) { - ctx.fs.logger.error(`path: ${ctx.path}, error: error`); + ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); ctx.status = 400; ctx.body = { message: typeof error == 'string' ? error : undefined @@ -30,7 +30,7 @@ async function projectAnxincloud (ctx) { ctx.status = 200; ctx.body = projectRes } catch (error) { - ctx.fs.logger.error(`path: ${ctx.path}, error: error`); + ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); ctx.status = 400; ctx.body = { message: typeof error == 'string' ? error : undefined @@ -43,12 +43,12 @@ async function projectPManage (ctx) { const models = ctx.fs.dc.models; const { clickHouse } = ctx.app.fs - const projectRes = await clickHouse.projectManage.query(`SELECT * FROM t_project WHERE project_state = 4 ORDER BY id DESC`).toPromise() + const projectRes = await clickHouse.projectManage.query(`SELECT id, project_name FROM t_pim_project WHERE isdelete=0 ORDER BY id DESC`).toPromise() ctx.status = 200; ctx.body = projectRes } catch (error) { - ctx.fs.logger.error(`path: ${ctx.path}, error: error`); + ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); ctx.status = 400; ctx.body = { message: typeof error == 'string' ? error : undefined diff --git a/api/app/lib/controllers/push/config.js b/api/app/lib/controllers/push/config.js index 2af88bb..3cbcdb0 100644 --- a/api/app/lib/controllers/push/config.js +++ b/api/app/lib/controllers/push/config.js @@ -37,7 +37,7 @@ async function list (ctx) { ctx.status = 200; ctx.body = listRes } catch (error) { - ctx.fs.logger.error(`path: ${ctx.path}, error: error`); + ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); ctx.status = 400; ctx.body = { message: typeof error == 'string' ? error : undefined @@ -68,7 +68,7 @@ async function edit (ctx) { ctx.status = 204; } catch (error) { - ctx.fs.logger.error(`path: ${ctx.path}, error: error`); + ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); ctx.status = 400; ctx.body = { message: typeof error == 'string' ? error : undefined @@ -100,7 +100,7 @@ async function state (ctx) { ctx.status = 204; } catch (error) { - ctx.fs.logger.error(`path: ${ctx.path}, error: error`); + ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); ctx.status = 400; ctx.body = { message: typeof error == 'string' ? error : undefined diff --git a/api/app/lib/middlewares/duration-calc.js b/api/app/lib/middlewares/duration-calc.js new file mode 100644 index 0000000..bd338c0 --- /dev/null +++ b/api/app/lib/middlewares/duration-calc.js @@ -0,0 +1,14 @@ +'use strict'; +const moment = require('moment'); + +async function factory (ctx, next) { + try { + const start = moment() + await next() + ctx.fs.logger.log(`DurationCalc: ${ctx.path} 用时 ${moment().diff(start, 'milliseconds')}`); + } catch (error) { + ctx.fs.logger.error(`DurationCalc, error: ${error}`); + } +} + +module.exports = factory; \ No newline at end of file diff --git a/api/app/lib/routes/organization/index.js b/api/app/lib/routes/organization/index.js index 48e17e6..4b26221 100644 --- a/api/app/lib/routes/organization/index.js +++ b/api/app/lib/routes/organization/index.js @@ -1,5 +1,4 @@ 'use strict'; - const organization = require('../../controllers/organization'); module.exports = function (app, router, opts) { diff --git a/web/client/assets/images/install/table_question.png b/web/client/assets/images/install/table_question.png index 5e3f55d..cfb8f76 100644 Binary files a/web/client/assets/images/install/table_question.png and b/web/client/assets/images/install/table_question.png differ diff --git a/web/client/src/sections/install/actions/roles.js b/web/client/src/sections/install/actions/roles.js index 20c078d..6081910 100644 --- a/web/client/src/sections/install/actions/roles.js +++ b/web/client/src/sections/install/actions/roles.js @@ -27,8 +27,10 @@ export function getOrganizationUser (query) {//获取成员列表 } export function putOrganizationUser (data) {//更新成员状态 let pomsUserId = '' + let msg = '' if (data) { pomsUserId = data.pomsUserId + msg=data.msg } return (dispatch) => basicAction({ @@ -37,12 +39,16 @@ export function putOrganizationUser (data) {//更新成员状态 data, actionType: "PUT_ORGANIZATIONUSER", url: `${ApiTable.putOrganizationUser.replace("{pomsUserId}", pomsUserId)}`, - msg: { option: "更新成员状态" }, //更新成员状态 + msg: { option: msg }, //更新成员状态 reducer: {}, }); } export function postOrganizationUser (data) {//添加/编辑成员 + let msg = '' + if (data) { + msg=data.msg + } return (dispatch) => basicAction({ type: "post", @@ -50,18 +56,24 @@ export function postOrganizationUser (data) {//添加/编辑成员 data, actionType: "POST_ORGANIZATION_USER", url: `${ApiTable.postOrganizationUser}`, - msg: { option: "添加/编辑成员" }, //添加/编辑成员 + msg: { option: msg }, //添加/编辑成员 reducer: { name: "" }, }); } -export function deteleOrganizationAdmin(orgId) { +export function deteleOrganizationAdmin(data) { + let pomsUserId = '' + let msg = '' + if (data) { + pomsUserId = data.id + msg=data.msg + } return (dispatch) => basicAction({ type: "del", dispatch: dispatch, actionType: "DEL_ORGANIZATION_ADMIN", - url: `${ApiTable.deteleOrganizationAdmin.replace("{pomsUserId}", orgId)}`, - msg: { option: "删除管理员" }, //删除管理员 + url: `${ApiTable.deteleOrganizationAdmin.replace("{pomsUserId}", pomsUserId)}`, + msg: { option: msg }, //删除管理员 reducer: {}, }); } \ No newline at end of file diff --git a/web/client/src/sections/install/components/adminModal.jsx b/web/client/src/sections/install/components/adminModal.jsx index 98a7b8c..6a03bf5 100644 --- a/web/client/src/sections/install/components/adminModal.jsx +++ b/web/client/src/sections/install/components/adminModal.jsx @@ -42,17 +42,17 @@ function adminModal (props) { .validate() .then((values) => { if (adminEdit) { - dispatch(install.deteleOrganizationAdmin(editObj.id)).then( - dispatch(install.postOrganizationUser({ role: ['admin'], pepUserId: values.pepUserId })).then((res) => {//获取项企(PEP)全部部门及其下用户 - if(res.success){ + dispatch(install.deteleOrganizationAdmin({id:editObj.id,msg:''})).then( + dispatch(install.postOrganizationUser({ role: ['admin'], pepUserId: values.pepUserId, msg: '修改管理员' })).then((res) => {//获取项企(PEP)全部部门及其下用户 + if (res.success) { close(); } }) ) } else { - dispatch(install.postOrganizationUser({ role: ['admin'], pepUserId: values.pepUserId })).then((res) => {//获取项企(PEP)全部部门及其下用户 - if(res.success){ + dispatch(install.postOrganizationUser({ role: ['admin'], pepUserId: values.pepUserId, msg: '新增管理员' })).then((res) => {//获取项企(PEP)全部部门及其下用户 + if (res.success) { close(); } }) @@ -77,7 +77,7 @@ function adminModal (props) {