2025-11-09 22:34:05 +08:00
|
|
|
|
package dto
|
|
|
|
|
|
|
2025-11-10 13:41:26 +08:00
|
|
|
|
import (
|
|
|
|
|
|
"time"
|
|
|
|
|
|
|
|
|
|
|
|
"git.huangwc.com/pig/pig-farm-controller/internal/infra/models"
|
|
|
|
|
|
)
|
|
|
|
|
|
|
2025-11-09 22:34:05 +08:00
|
|
|
|
// SnoozeAlarmRequest 定义了忽略告警的请求体
|
|
|
|
|
|
type SnoozeAlarmRequest struct {
|
|
|
|
|
|
DurationMinutes uint `json:"duration_minutes" validate:"required,min=1"` // 忽略时长,单位分钟
|
|
|
|
|
|
}
|
2025-11-10 13:41:26 +08:00
|
|
|
|
|
|
|
|
|
|
// 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"`
|
|
|
|
|
|
}
|
2025-11-10 17:35:22 +08:00
|
|
|
|
|
|
|
|
|
|
// CreateDeviceThresholdAlarmDTO 创建设备阈值告警的请求DTO
|
|
|
|
|
|
type CreateDeviceThresholdAlarmDTO struct {
|
|
|
|
|
|
DeviceID uint `json:"device_id" binding:"required"` // 设备ID
|
|
|
|
|
|
SensorType models.SensorType `json:"sensor_type" binding:"required"` // 传感器类型
|
|
|
|
|
|
Thresholds float64 `json:"thresholds" binding:"required"` // 阈值
|
|
|
|
|
|
Operator models.Operator `json:"operator" binding:"required"` // 操作符 (使用string类型,与前端交互更通用)
|
|
|
|
|
|
Level models.SeverityLevel `json:"level,omitempty"` // 告警等级,可选,如果未提供则使用默认值
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// UpdateDeviceThresholdAlarmDTO 更新设备阈值告警的请求DTO
|
|
|
|
|
|
type UpdateDeviceThresholdAlarmDTO struct {
|
|
|
|
|
|
Thresholds float64 `json:"thresholds" binding:"required"` // 新的阈值
|
|
|
|
|
|
Operator models.Operator `json:"operator" binding:"required"` // 新的操作符
|
|
|
|
|
|
Level models.SeverityLevel `json:"level,omitempty"` // 新的告警等级,可选
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// CreateAreaThresholdAlarmDTO 创建区域阈值告警的请求DTO
|
|
|
|
|
|
type CreateAreaThresholdAlarmDTO struct {
|
|
|
|
|
|
AreaControllerID uint `json:"area_controller_id" binding:"required"` // 区域主控ID
|
|
|
|
|
|
SensorType models.SensorType `json:"sensor_type" binding:"required"` // 传感器类型
|
|
|
|
|
|
Thresholds float64 `json:"thresholds" binding:"required"` // 阈值
|
|
|
|
|
|
Operator models.Operator `json:"operator" binding:"required"` // 操作符
|
|
|
|
|
|
Level models.SeverityLevel `json:"level,omitempty"` // 告警等级,可选
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// UpdateAreaThresholdAlarmDTO 更新区域阈值告警的请求DTO
|
|
|
|
|
|
type UpdateAreaThresholdAlarmDTO struct {
|
|
|
|
|
|
Thresholds float64 `json:"thresholds" binding:"required"` // 新的阈值
|
|
|
|
|
|
Operator models.Operator `json:"operator" binding:"required"` // 新的操作符
|
|
|
|
|
|
Level models.SeverityLevel `json:"level,omitempty"` // 新的告警等级,可选
|
|
|
|
|
|
}
|