package handlers

import (
	"net/http"

	"go-server/internal/service"

	"github.com/gin-gonic/gin"
)

type NutrientController struct {
	service *service.NutrientService
}

func NewNutrientController(service *service.NutrientService) *NutrientController {
	return &NutrientController{service}
}

func (c *NutrientController) GetAll(ctx *gin.Context) {
	nutrients, err := c.service.GetAll(ctx)
	if err != nil {
		ctx.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
		return
	}
	ctx.JSON(http.StatusOK, nutrients)
}
