This commit is contained in:
2025-11-03 12:24:01 +02:00
commit 0806865287
177 changed files with 18453 additions and 0 deletions

View File

@@ -0,0 +1,43 @@
package service
import (
"context"
"go-server/internal/models"
"go-server/internal/repository"
)
type SupplementService struct {
repo *repository.SupplementRepository
nutrientRepo *repository.NutrientRepository
}
func NewSupplementService(repo *repository.SupplementRepository, nutrientRepo *repository.NutrientRepository) *SupplementService {
return &SupplementService{repo: repo, nutrientRepo: nutrientRepo}
}
func (s *SupplementService) GetAll(ctx context.Context) ([]*models.Supplement, error) {
return s.repo.GetAll(ctx)
}
func (s *SupplementService) GetDailySupplementsOverview(ctx context.Context) (*models.DailySupplementsOverview, error) {
supplements, err := s.repo.GetAll(ctx)
if err != nil {
return nil, err
}
nutrients, err := s.nutrientRepo.GetAll(ctx)
if err != nil {
return nil, err
}
overview, err := s.repo.GetDailySupplementsOverview(ctx)
if err != nil {
return nil, err
}
return &models.DailySupplementsOverview{
Supplements: supplements,
Nutrients: nutrients,
Overview: overview,
}, nil
}