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 => {
return {
time: moment().format(),
alarmConfirmId: r.id
time: r.confirmTime,
alarmConfirmId: r.id,
projectCorrelationId: r.projectCorrelationId,
type: 4//告警确认
}
})
await models.AlarmConfirmLog.bulkCreate(dynamics);
await models.LatestDynamicList.bulkCreate(dynamics);
ctx.status = 204;

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

@ -22,8 +22,16 @@ async function getWorkbench(ctx) {
async function getProjectsInfo(ctx) {
try {
const { models } = ctx.fs.dc;
const { clickHouse } = ctx.app.fs
const { alarmId, limit, page } = ctx.query
const { clickHouse } = ctx.app.fs;
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.body = []
} catch (error) {
@ -56,11 +64,11 @@ async function getBiAnalysis(ctx) {
async function getLatestDynamic(ctx) {
try {
const { models } = ctx.fs.dc;
const { limit, page, projectCorrelationId } = ctx.query;
const { limit, page, projectCorrelationId, types } = ctx.query;
const { userInfo } = ctx.fs.api;
const { clickHouse } = ctx.app.fs;
let where = {}
let where = { type: { $in: types.split(',') } }//传类型选择
if (!userInfo.role.includes('SuperAdmin') && !userInfo.role.includes('admin')) {
where.projectCorrelationId = { $in: userInfo.correlationProject }
}

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

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

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

@ -60,6 +60,15 @@ module.exports = dc => {
primaryKey: false,
field: "project_correlation_id",
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",

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);
//最新动态
app.fs.api.logAttr['GET/user/:userId/latest/dynamic'] = { content: '查询最新动态', visible: false };
router.get('/user/:userId/latest/dynamic', console.getLatestDynamic);
app.fs.api.logAttr['GET/latest/dynamic'] = { content: '查询最新动态', visible: false };
router.get('/latest/dynamic', console.getLatestDynamic);
};

Loading…
Cancel
Save