51 lines
		
	
	
		
			2.0 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			51 lines
		
	
	
		
			2.0 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
package dto
 | 
						|
 | 
						|
import (
 | 
						|
	"time"
 | 
						|
 | 
						|
	"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"
 | 
						|
)
 | 
						|
 | 
						|
// SendTestNotificationRequest 定义了发送测试通知请求的 JSON 结构
 | 
						|
type SendTestNotificationRequest struct {
 | 
						|
	// Type 指定要测试的通知渠道
 | 
						|
	Type notify.NotifierType `json:"type" binding:"required"`
 | 
						|
}
 | 
						|
 | 
						|
// ListNotificationRequest 定义了获取通知列表的请求参数
 | 
						|
type ListNotificationRequest struct {
 | 
						|
	Page         int                        `form:"page,default=1"`
 | 
						|
	PageSize     int                        `form:"pageSize,default=10"`
 | 
						|
	UserID       *uint                      `form:"user_id"`
 | 
						|
	NotifierType *notify.NotifierType       `form:"notifier_type"`
 | 
						|
	Status       *models.NotificationStatus `form:"status"`
 | 
						|
	Level        *zapcore.Level             `form:"level"`
 | 
						|
	StartTime    *time.Time                 `form:"start_time"`
 | 
						|
	EndTime      *time.Time                 `form:"end_time"`
 | 
						|
	OrderBy      string                     `form:"order_by"`
 | 
						|
}
 | 
						|
 | 
						|
// NotificationDTO 是用于API响应的通知结构
 | 
						|
type NotificationDTO struct {
 | 
						|
	ID             uint                      `json:"id"`
 | 
						|
	CreatedAt      time.Time                 `json:"created_at"`
 | 
						|
	UpdatedAt      time.Time                 `json:"updated_at"`
 | 
						|
	NotifierType   notify.NotifierType       `json:"notifier_type"`
 | 
						|
	UserID         uint                      `json:"user_id"`
 | 
						|
	Title          string                    `json:"title"`
 | 
						|
	Message        string                    `json:"message"`
 | 
						|
	Level          zapcore.Level             `json:"level"`
 | 
						|
	AlarmTimestamp time.Time                 `json:"alarm_timestamp"`
 | 
						|
	ToAddress      string                    `json:"to_address"`
 | 
						|
	Status         models.NotificationStatus `json:"status"`
 | 
						|
	ErrorMessage   string                    `json:"error_message"`
 | 
						|
}
 | 
						|
 | 
						|
// ListNotificationResponse 是获取通知列表的响应结构
 | 
						|
type ListNotificationResponse struct {
 | 
						|
	List       []NotificationDTO `json:"list"`
 | 
						|
	Pagination PaginationDTO     `json:"pagination"`
 | 
						|
}
 |