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 }