Browse Source

(*)获取控制台最新动态接口修改,传选择类型

dev
wuqun 2 years ago
parent
commit
878eb3a1e4
  1. 8
      api/app/lib/controllers/alarm/app.js
  2. 16
      api/app/lib/controllers/console/index.js
  3. 9
      api/app/lib/models/alarm_appear_record.js
  4. 9
      api/app/lib/models/latest_dynamic_list.js
  5. 4
      api/app/lib/routes/console/index.js

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

@ -353,11 +353,13 @@ async function confirmApiError(ctx) {
//存最新动态 //存最新动态
let dynamics = rslt.map(r => { let dynamics = rslt.map(r => {
return { return {
time: moment().format(), time: r.confirmTime,
alarmConfirmId: r.id alarmConfirmId: r.id,
projectCorrelationId: r.projectCorrelationId,
type: 4//告警确认
} }
}) })
await models.AlarmConfirmLog.bulkCreate(dynamics); await models.LatestDynamicList.bulkCreate(dynamics);
ctx.status = 204; ctx.status = 204;

16
api/app/lib/controllers/console/index.js

@ -22,8 +22,16 @@ async function getWorkbench(ctx) {
async function getProjectsInfo(ctx) { async function getProjectsInfo(ctx) {
try { try {
const { models } = ctx.fs.dc; const { models } = ctx.fs.dc;
const { clickHouse } = ctx.app.fs const { clickHouse } = ctx.app.fs;
const { alarmId, limit, page } = ctx.query const { alarmId, limit, page, projectCorrelationId } = ctx.query;
const { userInfo } = ctx.fs.api;
let where = {}
if (!userInfo.role.includes('SuperAdmin') && !userInfo.role.includes('admin')) {
where.projectCorrelationId = { $in: userInfo.correlationProject }
}
if (projectCorrelationId) {//查指定项目,控制台全局切换
where.projectCorrelationId = projectCorrelationId
}
ctx.status = 200; ctx.status = 200;
ctx.body = [] ctx.body = []
} catch (error) { } catch (error) {
@ -56,11 +64,11 @@ async function getBiAnalysis(ctx) {
async function getLatestDynamic(ctx) { async function getLatestDynamic(ctx) {
try { try {
const { models } = ctx.fs.dc; const { models } = ctx.fs.dc;
const { limit, page, projectCorrelationId } = ctx.query; const { limit, page, projectCorrelationId, types } = ctx.query;
const { userInfo } = ctx.fs.api; const { userInfo } = ctx.fs.api;
const { clickHouse } = ctx.app.fs; const { clickHouse } = ctx.app.fs;
let where = {} let where = { type: { $in: types.split(',') } }//传类型选择
if (!userInfo.role.includes('SuperAdmin') && !userInfo.role.includes('admin')) { if (!userInfo.role.includes('SuperAdmin') && !userInfo.role.includes('admin')) {
where.projectCorrelationId = { $in: userInfo.correlationProject } where.projectCorrelationId = { $in: userInfo.correlationProject }
} }

9
api/app/lib/models/alarm_appear_record.js

@ -42,6 +42,15 @@ module.exports = dc => {
primaryKey: false, primaryKey: false,
field: "time", field: "time",
autoIncrement: false autoIncrement: false
},
type: {
type: DataTypes.STRING,
allowNull: true,
defaultValue: null,
comment: "数据告警:data,设备告警:device,应用告警:application",
primaryKey: false,
field: "type",
autoIncrement: false
} }
}, { }, {
tableName: "alarm_appear_record", tableName: "alarm_appear_record",

9
api/app/lib/models/latest_dynamic_list.js

@ -60,6 +60,15 @@ module.exports = dc => {
primaryKey: false, primaryKey: false,
field: "project_correlation_id", field: "project_correlation_id",
autoIncrement: false autoIncrement: false
},
type: {
type: DataTypes.INTEGER,
allowNull: true,
defaultValue: null,
comment: '1:发现,2:通知,3:处置,4:确认',
primaryKey: false,
field: "type",
autoIncrement: false
} }
}, { }, {
tableName: "latest_dynamic_list", tableName: "latest_dynamic_list",

4
api/app/lib/routes/console/index.js

@ -18,6 +18,6 @@ module.exports = function (app, router, opts) {
router.get('/user/:userId/bi/analysis', console.getBiAnalysis); router.get('/user/:userId/bi/analysis', console.getBiAnalysis);
//最新动态 //最新动态
app.fs.api.logAttr['GET/user/:userId/latest/dynamic'] = { content: '查询最新动态', visible: false }; app.fs.api.logAttr['GET/latest/dynamic'] = { content: '查询最新动态', visible: false };
router.get('/user/:userId/latest/dynamic', console.getLatestDynamic); router.get('/latest/dynamic', console.getLatestDynamic);
}; };

Loading…
Cancel
Save