实现service层
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
||||
|
||||
"git.huangwc.com/pig/pig-farm-controller/internal/infra/models"
|
||||
"git.huangwc.com/pig/pig-farm-controller/internal/infra/notify"
|
||||
"go.uber.org/zap/zapcore"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
@@ -13,6 +14,7 @@ type NotificationListOptions struct {
|
||||
UserID *uint // 按用户ID过滤
|
||||
NotifierType *notify.NotifierType // 按通知器类型过滤
|
||||
Status *string // 按通知状态过滤 (例如:"success", "failed", "pending")
|
||||
Level *zapcore.Level // 按通知等级过滤 (例如:"info", "warning", "error")
|
||||
StartTime *time.Time // 通知内容生成时间范围 - 开始时间 (对应 AlarmTimestamp)
|
||||
EndTime *time.Time // 通知内容生成时间范围 - 结束时间 (对应 AlarmTimestamp)
|
||||
OrderBy string // 排序字段,例如 "alarm_timestamp DESC"
|
||||
@@ -79,6 +81,9 @@ func (r *gormNotificationRepository) List(opts NotificationListOptions, page, pa
|
||||
if opts.Status != nil {
|
||||
query = query.Where("status = ?", *opts.Status)
|
||||
}
|
||||
if opts.Level != nil {
|
||||
query = query.Where("level = ?", opts.Level.String())
|
||||
}
|
||||
if opts.StartTime != nil {
|
||||
query = query.Where("alarm_timestamp >= ?", *opts.StartTime)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user