package services

import (
	"messageService/internal/app/models"
	"messageService/internal/app/repositories"
)

type MessageService interface {
	GetAllMessages() ([]models.Message, error)
	GetMessagesByStreamID(streamId uint) ([]models.Message, error)
	GetMessageByID(id uint) (*models.Message, error)
	CreateMessage(message *models.Message) error
	UpdateMessage(message *models.Message) error
	DeleteMessage(id uint) error
}

type messageService struct {
	repo repositories.MessageRepository
}

func NewMessageService(repo repositories.MessageRepository) MessageService {
	return &messageService{repo}
}

func (s *messageService) GetAllMessages() ([]models.Message, error) {
	return s.repo.GetAllMessages()
}

func (s *messageService) GetMessagesByStreamID(streamId uint) ([]models.Message, error) {
	return s.repo.GetMessagesByStreamID(streamId)
}

func (s *messageService) GetMessageByID(id uint) (*models.Message, error) {
	return s.repo.GetMessageByID(id)
}

func (s *messageService) CreateMessage(message *models.Message) error {
	return s.repo.CreateMessage(message)
}

func (s *messageService) UpdateMessage(message *models.Message) error {
	return s.repo.UpdateMessage(message)
}

func (s *messageService) DeleteMessage(id uint) error {
	return s.repo.DeleteMessage(id)
}
