package service

import (
    "context"
	"github.com/go-nunu/nunu-layout-advanced/internal/model"
	"github.com/go-nunu/nunu-layout-advanced/internal/repository"
)

type LogService interface {
	GetLog(ctx context.Context, id int64) (*model.Log, error)
	AddLog(ctx context.Context, log *model.Log) error
	EditLog(ctx context.Context, log *model.Log) error
}
func NewLogService(
    service *Service,
    logRepository repository.LogRepository,
) LogService {
	return &logService{
		Service:        service,
		logRepository: logRepository,
	}
}

type logService struct {
	*Service
	logRepository repository.LogRepository
}

func (s *logService) GetLog(ctx context.Context, id int64) (*model.Log, error) {
	return s.logRepository.GetLog(ctx, id)
}

func (s *logService) AddLog(ctx context.Context, log *model.Log) error {
	if err := s.logRepository.AddLog(ctx, log); err != nil {
		return err
	}
	return nil
}

func (s *logService) EditLog(ctx context.Context, log *model.Log) error {
	if err := s.logRepository.EditLog(ctx, log); err != nil {
		return err
	}
	return nil
}
