package dto

import (
	"git.huangwc.com/pig/pig-farm-controller/internal/infra/models"
)

// NewListNotificationResponse 从模型数据创建通知列表响应 DTO
func NewListNotificationResponse(data []models.Notification, total int64, page, pageSize int) *ListNotificationResponse {
	dtos := make([]NotificationDTO, len(data))
	for i, item := range data {
		dtos[i] = NotificationDTO{
			ID:             item.ID,
			CreatedAt:      item.CreatedAt,
			UpdatedAt:      item.UpdatedAt,
			NotifierType:   item.NotifierType,
			UserID:         item.UserID,
			Title:          item.Title,
			Message:        item.Message,
			Level:          item.Level,
			AlarmTimestamp: item.AlarmTimestamp,
			ToAddress:      item.ToAddress,
			Status:         item.Status,
			ErrorMessage:   item.ErrorMessage,
		}
	}

	return &ListNotificationResponse{
		List: dtos,
		Pagination: PaginationDTO{
			Total:    total,
			Page:     page,
			PageSize: pageSize,
		},
	}
}
