mirror of
https://gitee.com/XM-GO/PandaX.git
synced 2026-04-23 10:58:35 +08:00
【feat】首页面板告警数据
This commit is contained in:
@@ -16,6 +16,7 @@ type (
|
||||
Update(data entity.DeviceAlarm) error
|
||||
Delete(ids []string)
|
||||
FindAlarmCount() entity.DeviceCount
|
||||
FindAlarmPanel() []entity.DeviceAlarmCount
|
||||
}
|
||||
|
||||
alarmModelImpl struct {
|
||||
@@ -102,3 +103,9 @@ func (m *alarmModelImpl) FindAlarmCount() (count entity.DeviceCount) {
|
||||
biz.ErrIsNil(err, "获取告警统计总数失败")
|
||||
return
|
||||
}
|
||||
func (m *alarmModelImpl) FindAlarmPanel() (count []entity.DeviceAlarmCount) {
|
||||
sql := `SELECT CAST(time AS DATE) AS date, COUNT(*) AS count FROM device_alarms WHERE time >= DATE_SUB(CURDATE(), INTERVAL 30 DAY) GROUP BY CAST(time AS DATE)`
|
||||
err := global.Db.Raw(sql).Scan(&count).Error
|
||||
biz.ErrIsNil(err, "获取告警统计列表失败")
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user