updates
This commit is contained in:
35
server/internal/handlers/supplement_handler.go
Normal file
35
server/internal/handlers/supplement_handler.go
Normal file
@@ -0,0 +1,35 @@
|
||||
package handlers
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"go-server/internal/service"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type SupplementController struct {
|
||||
service *service.SupplementService
|
||||
}
|
||||
|
||||
func NewSupplementController(service *service.SupplementService) *SupplementController {
|
||||
return &SupplementController{service}
|
||||
}
|
||||
|
||||
func (c *SupplementController) GetAll(ctx *gin.Context) {
|
||||
supplements, err := c.service.GetAll(ctx)
|
||||
if err != nil {
|
||||
ctx.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
ctx.JSON(http.StatusOK, supplements)
|
||||
}
|
||||
|
||||
func (c *SupplementController) GetDailySupplementsOverview(ctx *gin.Context) {
|
||||
supplements, err := c.service.GetDailySupplementsOverview(ctx)
|
||||
if err != nil {
|
||||
ctx.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
ctx.JSON(http.StatusOK, supplements)
|
||||
}
|
||||
Reference in New Issue
Block a user