Browse Source

fix 映射关系自定义项目修改为选择PEP项目时选择已绑定过的PEP项目可以成功

dev
巴林闲侠 2 years ago
parent
commit
6698bf9087
  1. 9
      api/.vscode/launch.json
  2. 8
      api/app/lib/controllers/alarm/data.js
  3. 24
      api/app/lib/controllers/project/bind.js
  4. 3
      api/app/lib/middlewares/authenticator.js
  5. 5
      api/app/lib/routes/alarm/index.js
  6. 1
      api/app/lib/service/clickHouseClient.js
  7. 35
      api/config.js

9
api/.vscode/launch.json

@ -39,10 +39,19 @@
// "--clickHouseUser ",
// "--clickHousePassword ",
//
// "--clickHouseAnxincloud anxinyun",
// "--clickHousePepEmis pepca",
// "--clickHouseProjectManage peppm",
// "--clickHouseVcmp video_accrss1",
// "--clickHouseDataAlarm default",
//
"--clickHouseAnxincloud Anxinyun8",
"--clickHousePepEmis pepca8",
"--clickHouseProjectManage peppm8",
"--clickHouseVcmp video_accrss1",
"--clickHouseDataAlarm default123",
]
},
{

8
api/app/lib/controllers/alarm/data.js

@ -3,8 +3,14 @@
async function list (ctx) {
try {
const models = ctx.fs.dc.models;
const { clickHouse } = ctx.app.fs
ctx.status = 20;
const alarmRes = await clickHouse.dataAlarm.query(`
SELECT * FROM alarms
`)
ctx.status = 200;
ctx.body = []
} catch (error) {
ctx.fs.logger.error(`path: ${ctx.path}, error: error`);
ctx.status = 400;

24
api/app/lib/controllers/project/bind.js

@ -55,6 +55,30 @@ async function bindAnxin2pep (ctx) {
})) {
throw `已有相同名称【${name}】的自定义项目`
}
} else {
const pomsRepeatProjectIdRes = await models.ProjectCorrelation.findAll({
where: {
pepProjectId: pepProjectId
}
})
if (pomsRepeatProjectIdRes.some((pr) => {
return (
(
// 有修改id但是不等于当前修改id的
bindId && pr.id != bindId && !pr.del
) || (
!bindId && (
(
existRes && pr.id != existRes.id && !pr.del
) || (
!existRes && !pr.del
)
)
)
)
})) {
throw `当前项企项目已绑定`
}
}
let storageData = {

3
api/app/lib/middlewares/authenticator.js

@ -86,8 +86,9 @@ let authorizeToken = async function (ctx, token) {
'resources': (userInfo || {}).resources || [],
};
ctx.fs.api.userId = pomsUser.id;
ctx.fs.api.userInfo = pomsUser;
ctx.fs.api.pepUserId = userInfo.id;
ctx.fs.api.userInfo = userInfo;
ctx.fs.api.pepUserInfo = userInfo;
ctx.fs.api.token = token;
}
} catch (err) {

5
api/app/lib/routes/alarm/index.js

@ -3,6 +3,7 @@
'use strict';
const application = require('../../controllers/alarm/app');
const dataAlarm = require('../../controllers/alarm/data');
module.exports = function (app, router, opts) {
// 应用告警
@ -24,5 +25,7 @@ module.exports = function (app, router, opts) {
app.fs.api.logAttr['POST/alarm/application/api_confirm'] = { content: '确认应用接口/元素错误信息', visible: true };
router.post('/alarm/application/api_confirm', application.confirmApiError);
//
// 数据告警
app.fs.api.logAttr['GET/alarm/data/list'] = { content: '查询数据告警列表', visible: true };
router.get('/alarm/data/list', dataAlarm.list);
};

1
api/app/lib/service/clickHouseClient.js

@ -21,6 +21,7 @@ function factory (app, opts) {
database: d.db,
},
})
console.info(`ClickHouse ${d.name} 初始化完成`);
} else {
throw 'opts.clickHouse 参数错误!'
}

35
api/config.js

@ -37,6 +37,7 @@ args.option('clickHouseAnxincloud', 'clickHouse 安心云数据库名称');
args.option('clickHousePepEmis', 'clickHouse 项企数据库名称');
args.option('clickHouseProjectManage', 'clickHouse 项目管理数据库名称');
args.option('clickHouseVcmp', 'clickHouse 视频平台数据库名称');
args.option('clickHouseDataAlarm', 'clickHouse 视频平台数据告警库名称');
const flags = args.parse(process.argv);
@ -75,6 +76,7 @@ const CLICKHOUST_ANXINCLOUD = process.env.CLICKHOUST_ANXINCLOUD || flags.clickHo
const CLICKHOUST_PEP_EMIS = process.env.CLICKHOUST_PEP_EMIS || flags.clickHousePepEmis
const CLICKHOUST_PROJECT_MANAGE = process.env.CLICKHOUST_PROJECT_MANAGE || flags.clickHouseProjectManage
const CLICKHOUST_VCMP = process.env.CLICKHOUST_VCMP || flags.clickHouseVcmp
const CLICKHOUST_DATA_ALARM = process.env.CLICKHOUST_DATA_ALARM || flags.clickHouseDataAlarm
if (
!POMS_DB
@ -84,7 +86,7 @@ if (
|| !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 || !CLICKHOUST_VCMP
|| !CLICKHOUST_ANXINCLOUD || !CLICKHOUST_PEP_EMIS || !CLICKHOUST_PROJECT_MANAGE || !CLICKHOUST_VCMP || !CLICKHOUST_DATA_ALARM
) {
console.log('缺少启动参数,异常退出');
args.showHelp();
@ -159,19 +161,24 @@ const product = {
port: CLICKHOUST_PORT,
user: CLICKHOUST_USER,
password: CLICKHOUST_PASSWORD,
db: [{
name: 'anxinyun',
db: CLICKHOUST_ANXINCLOUD
}, {
name: 'pepEmis',
db: CLICKHOUST_PEP_EMIS
}, {
name: 'projectManage',
db: CLICKHOUST_PROJECT_MANAGE
}, {
name: 'vcmp',
db: CLICKHOUST_VCMP
},]
db: [
{
name: 'anxinyun',
db: CLICKHOUST_ANXINCLOUD
}, {
name: 'pepEmis',
db: CLICKHOUST_PEP_EMIS
}, {
name: 'projectManage',
db: CLICKHOUST_PROJECT_MANAGE
}, {
name: 'vcmp',
db: CLICKHOUST_VCMP
}, {
name: 'dataAlarm',
db: CLICKHOUST_DATA_ALARM
}
]
}
}
}

Loading…
Cancel
Save