package service

import (
	"github.com/rs/zerolog"

	"web-qudo-be/app/module/popup_news_content_images/repository"
	"web-qudo-be/app/module/popup_news_content_images/request"
)

// service struct
type popupNewsContentImagesService struct {
	Repo repository.PopupNewsContentImagesRepository
	Log  zerolog.Logger
}

// interface
type PopupNewsContentImagesService interface {
	Save(req request.PopupNewsContentImagesCreateRequest) error
	Delete(id uint) error
}

// constructor
func NewPopupNewsContentImagesService(repo repository.PopupNewsContentImagesRepository, log zerolog.Logger) PopupNewsContentImagesService {
	return &popupNewsContentImagesService{
		Repo: repo,
		Log:  log,
	}
}

// Save
func (_i *popupNewsContentImagesService) Save(req request.PopupNewsContentImagesCreateRequest) error {
	_i.Log.Info().Interface("data", req).Msg("upload popup news content image")

	return _i.Repo.Create(req.ToEntity())
}

// Delete
func (_i *popupNewsContentImagesService) Delete(id uint) error {
	return _i.Repo.Delete(id)
}