实现列表查询活跃告警和历史告警
This commit is contained in:
@@ -1,6 +1,83 @@
|
||||
package dto
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"git.huangwc.com/pig/pig-farm-controller/internal/infra/models"
|
||||
)
|
||||
|
||||
// SnoozeAlarmRequest 定义了忽略告警的请求体
|
||||
type SnoozeAlarmRequest struct {
|
||||
DurationMinutes uint `json:"duration_minutes" validate:"required,min=1"` // 忽略时长,单位分钟
|
||||
}
|
||||
|
||||
// ListActiveAlarmRequest 定义了获取活跃告警列表的请求参数
|
||||
type ListActiveAlarmRequest struct {
|
||||
Page int `json:"page" query:"page"`
|
||||
PageSize int `json:"page_size" query:"page_size"`
|
||||
SourceType *models.AlarmSourceType `json:"source_type" query:"source_type"` // 按告警来源类型过滤
|
||||
SourceID *uint `json:"source_id" query:"source_id"` // 按告警来源ID过滤
|
||||
Level *models.SeverityLevel `json:"level" query:"level"` // 按告警严重性等级过滤
|
||||
IsIgnored *bool `json:"is_ignored" query:"is_ignored"` // 按是否被忽略过滤
|
||||
TriggerTime *time.Time `json:"trigger_time" query:"trigger_time"` // 告警触发时间范围 - 开始时间
|
||||
EndTime *time.Time `json:"end_time" query:"end_time"` // 告警触发时间范围 - 结束时间
|
||||
OrderBy string `json:"order_by" query:"order_by"` // 排序字段,例如 "trigger_time DESC"
|
||||
}
|
||||
|
||||
// ActiveAlarmDTO 是用于API响应的活跃告警结构
|
||||
type ActiveAlarmDTO struct {
|
||||
ID uint `json:"id"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
SourceType models.AlarmSourceType `json:"source_type"`
|
||||
SourceID uint `json:"source_id"`
|
||||
AlarmCode models.AlarmCode `json:"alarm_code"`
|
||||
AlarmSummary string `json:"alarm_summary"`
|
||||
Level models.SeverityLevel `json:"level"`
|
||||
AlarmDetails string `json:"alarm_details"`
|
||||
TriggerTime time.Time `json:"trigger_time"`
|
||||
IsIgnored bool `json:"is_ignored"`
|
||||
IgnoredUntil *time.Time `json:"ignored_until"`
|
||||
LastNotifiedAt *time.Time `json:"last_notified_at"`
|
||||
}
|
||||
|
||||
// ListActiveAlarmResponse 是获取活跃告警列表的响应结构
|
||||
type ListActiveAlarmResponse struct {
|
||||
List []ActiveAlarmDTO `json:"list"`
|
||||
Pagination PaginationDTO `json:"pagination"`
|
||||
}
|
||||
|
||||
// ListHistoricalAlarmRequest 定义了获取历史告警列表的请求参数
|
||||
type ListHistoricalAlarmRequest struct {
|
||||
Page int `json:"page" query:"page"`
|
||||
PageSize int `json:"page_size" query:"page_size"`
|
||||
SourceType *models.AlarmSourceType `json:"source_type" query:"source_type"` // 按告警来源类型过滤
|
||||
SourceID *uint `json:"source_id" query:"source_id"` // 按告警来源ID过滤
|
||||
Level *models.SeverityLevel `json:"level" query:"level"` // 按告警严重性等级过滤
|
||||
TriggerTimeStart *time.Time `json:"trigger_time_start" query:"trigger_time_start"` // 告警触发时间范围 - 开始时间
|
||||
TriggerTimeEnd *time.Time `json:"trigger_time_end" query:"trigger_time_end"` // 告警触发时间范围 - 结束时间
|
||||
ResolveTimeStart *time.Time `json:"resolve_time_start" query:"resolve_time_start"` // 告警解决时间范围 - 开始时间
|
||||
ResolveTimeEnd *time.Time `json:"resolve_time_end" query:"resolve_time_end"` // 告警解决时间范围 - 结束时间
|
||||
OrderBy string `json:"order_by" query:"order_by"` // 排序字段,例如 "trigger_time DESC"
|
||||
}
|
||||
|
||||
// HistoricalAlarmDTO 是用于API响应的历史告警结构
|
||||
type HistoricalAlarmDTO struct {
|
||||
ID uint `json:"id"`
|
||||
SourceType models.AlarmSourceType `json:"source_type"`
|
||||
SourceID uint `json:"source_id"`
|
||||
AlarmCode models.AlarmCode `json:"alarm_code"`
|
||||
AlarmSummary string `json:"alarm_summary"`
|
||||
Level models.SeverityLevel `json:"level"`
|
||||
AlarmDetails string `json:"alarm_details"`
|
||||
TriggerTime time.Time `json:"trigger_time"`
|
||||
ResolveTime time.Time `json:"resolve_time"`
|
||||
ResolveMethod string `json:"resolve_method"`
|
||||
ResolvedBy *uint `json:"resolved_by"`
|
||||
}
|
||||
|
||||
// ListHistoricalAlarmResponse 是获取历史告警列表的响应结构
|
||||
type ListHistoricalAlarmResponse struct {
|
||||
List []HistoricalAlarmDTO `json:"list"`
|
||||
Pagination PaginationDTO `json:"pagination"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user