uint/uint64全部改为uint32
This commit is contained in:
@@ -18,9 +18,9 @@ import (
|
||||
// 该服务负责管理阈值告警任务的配置,并将其与计划进行联动。
|
||||
type ThresholdAlarmService interface {
|
||||
// SnoozeThresholdAlarm 忽略一个阈值告警,或更新其忽略时间。
|
||||
SnoozeThresholdAlarm(ctx context.Context, alarmID uint, durationMinutes uint) error
|
||||
SnoozeThresholdAlarm(ctx context.Context, alarmID uint32, durationMinutes uint32) error
|
||||
// CancelSnoozeThresholdAlarm 取消对一个阈值告警的忽略状态。
|
||||
CancelSnoozeThresholdAlarm(ctx context.Context, alarmID uint) error
|
||||
CancelSnoozeThresholdAlarm(ctx context.Context, alarmID uint32) error
|
||||
// ListActiveAlarms 批量查询活跃告警。
|
||||
ListActiveAlarms(ctx context.Context, req *dto.ListActiveAlarmRequest) (*dto.ListActiveAlarmResponse, error)
|
||||
// ListHistoricalAlarms 批量查询历史告警。
|
||||
@@ -35,7 +35,7 @@ type ThresholdAlarmService interface {
|
||||
// DeleteDeviceThresholdAlarm 删除一个设备阈值告警。
|
||||
DeleteDeviceThresholdAlarm(ctx context.Context, taskID int, req *dto.DeleteDeviceThresholdAlarmDTO) error
|
||||
// DeleteDeviceThresholdAlarmByDeviceID 实现了根据设备ID删除一个设备下所有设备阈值告警的逻辑。
|
||||
DeleteDeviceThresholdAlarmByDeviceID(ctx context.Context, deviceID uint) error
|
||||
DeleteDeviceThresholdAlarmByDeviceID(ctx context.Context, deviceID uint32) error
|
||||
|
||||
// CreateAreaThresholdAlarm 创建一个区域阈值告警。
|
||||
CreateAreaThresholdAlarm(ctx context.Context, req *dto.CreateAreaThresholdAlarmDTO) error
|
||||
@@ -46,7 +46,7 @@ type ThresholdAlarmService interface {
|
||||
// DeleteAreaThresholdAlarm 实现了删除一个区域阈值告警的逻辑。
|
||||
DeleteAreaThresholdAlarm(ctx context.Context, taskID int) error
|
||||
// DeleteAreaThresholdAlarmByAreaControllerID 实现了根据区域ID删除一个区域下所有区域阈值告警的逻辑。
|
||||
DeleteAreaThresholdAlarmByAreaControllerID(ctx context.Context, areaControllerID uint) error
|
||||
DeleteAreaThresholdAlarmByAreaControllerID(ctx context.Context, areaControllerID uint32) error
|
||||
}
|
||||
|
||||
// thresholdAlarmService 是 ThresholdAlarmService 接口的具体实现。
|
||||
@@ -82,13 +82,13 @@ func NewThresholdAlarmService(ctx context.Context,
|
||||
}
|
||||
|
||||
// SnoozeThresholdAlarm 实现了忽略阈值告警的逻辑。
|
||||
func (s *thresholdAlarmService) SnoozeThresholdAlarm(ctx context.Context, alarmID uint, durationMinutes uint) error {
|
||||
func (s *thresholdAlarmService) SnoozeThresholdAlarm(ctx context.Context, alarmID uint32, durationMinutes uint32) error {
|
||||
serviceCtx := logs.AddFuncName(ctx, s.ctx, "SnoozeThresholdAlarm")
|
||||
return s.alarmService.SnoozeAlarm(serviceCtx, alarmID, time.Duration(durationMinutes)*time.Minute)
|
||||
}
|
||||
|
||||
// CancelSnoozeThresholdAlarm 实现了取消忽略阈值告警的逻辑。
|
||||
func (s *thresholdAlarmService) CancelSnoozeThresholdAlarm(ctx context.Context, alarmID uint) error {
|
||||
func (s *thresholdAlarmService) CancelSnoozeThresholdAlarm(ctx context.Context, alarmID uint32) error {
|
||||
serviceCtx := logs.AddFuncName(ctx, s.ctx, "CancelSnoozeThresholdAlarm")
|
||||
return s.alarmService.CancelAlarmSnooze(serviceCtx, alarmID)
|
||||
}
|
||||
@@ -169,7 +169,7 @@ func (s *thresholdAlarmService) CreateDeviceThresholdAlarm(ctx context.Context,
|
||||
}
|
||||
case models.TaskTypeAreaCollectorThresholdCheck: // 向区域阈值检查任务过滤列表中添加该设备
|
||||
params := task.AreaThresholdCheckParams{
|
||||
ExcludeDeviceIDs: []uint{},
|
||||
ExcludeDeviceIDs: []uint32{},
|
||||
}
|
||||
err = t.ParseParameters(¶ms)
|
||||
if err != nil {
|
||||
@@ -375,7 +375,7 @@ func (s *thresholdAlarmService) DeleteDeviceThresholdAlarm(ctx context.Context,
|
||||
}
|
||||
|
||||
// DeleteDeviceThresholdAlarmByDeviceID 实现了根据设备ID删除一个设备下所有设备阈值告警的逻辑。
|
||||
func (s *thresholdAlarmService) DeleteDeviceThresholdAlarmByDeviceID(ctx context.Context, deviceID uint) error {
|
||||
func (s *thresholdAlarmService) DeleteDeviceThresholdAlarmByDeviceID(ctx context.Context, deviceID uint32) error {
|
||||
serviceCtx, logger := logs.Trace(ctx, s.ctx, "DeleteDeviceThresholdAlarmByDeviceID")
|
||||
tasks, err := s.planRepo.ListTasksByDeviceID(serviceCtx, deviceID)
|
||||
if err != nil {
|
||||
@@ -462,13 +462,13 @@ func (s *thresholdAlarmService) CreateAreaThresholdAlarm(ctx context.Context, re
|
||||
if err != nil {
|
||||
return fmt.Errorf("获取区域 %d 下的设备列表失败: %w", req.AreaControllerID, err)
|
||||
}
|
||||
devicesInAreaMap := make(map[uint]struct{}, len(devicesInArea))
|
||||
devicesInAreaMap := make(map[uint32]struct{}, len(devicesInArea))
|
||||
for _, device := range devicesInArea {
|
||||
devicesInAreaMap[device.ID] = struct{}{}
|
||||
}
|
||||
|
||||
// 3. 遍历计划,检查存在性并收集需要排除的设备ID
|
||||
var excludeDeviceIDs []uint
|
||||
var excludeDeviceIDs []uint32
|
||||
for _, t := range plan.Tasks {
|
||||
switch t.Type {
|
||||
case models.TaskTypeAreaCollectorThresholdCheck:
|
||||
@@ -631,7 +631,7 @@ func (s *thresholdAlarmService) DeleteAreaThresholdAlarm(ctx context.Context, ta
|
||||
}
|
||||
|
||||
// DeleteAreaThresholdAlarmByAreaControllerID 实现了根据区域ID删除一个区域下所有区域阈值告警的逻辑。
|
||||
func (s *thresholdAlarmService) DeleteAreaThresholdAlarmByAreaControllerID(ctx context.Context, areaControllerID uint) error {
|
||||
func (s *thresholdAlarmService) DeleteAreaThresholdAlarmByAreaControllerID(ctx context.Context, areaControllerID uint32) error {
|
||||
serviceCtx, logger := logs.Trace(ctx, s.ctx, "DeleteAreaThresholdAlarmByAreaControllerID")
|
||||
|
||||
// 1. 获取系统健康检查计划
|
||||
|
||||
Reference in New Issue
Block a user