From 77bd0a5f86e90738db45662542fb2dab0f5f4df8 Mon Sep 17 00:00:00 2001 From: matze Date: Thu, 10 Apr 2025 17:30:55 +0200 Subject: [PATCH] Update wagfarm-api/routes/log/log_routes.go --- wagfarm-api/routes/log/log_routes.go | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/wagfarm-api/routes/log/log_routes.go b/wagfarm-api/routes/log/log_routes.go index 55e8245..7f4a1a0 100644 --- a/wagfarm-api/routes/log/log_routes.go +++ b/wagfarm-api/routes/log/log_routes.go @@ -12,15 +12,15 @@ func RegisterRoutes(router *gin.Engine) { db := database.DB group := router.Group("/log") - RegisterHarvestRoutes(router, path) + RegisterHarvestRoutes(group) - router.GET(path+"-type", func(c *gin.Context) { + group.GET("/type", func(c *gin.Context) { var types []models.LogType db.Find(&types) c.JSON(http.StatusOK, types) }) - router.POST(path+"-type", func(c *gin.Context) { + group.POST("/type", func(c *gin.Context) { var logType models.LogType if err := c.ShouldBindJSON(&logType); err != nil { c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()}) @@ -30,19 +30,9 @@ func RegisterRoutes(router *gin.Engine) { c.JSON(http.StatusCreated, logType) }) - router.GET(path, func(c *gin.Context) { + group.GET("/", func(c *gin.Context) { var logs []models.Log db.Preload("LogType").Preload("Equipment").Preload("Substance").Find(&logs) c.JSON(http.StatusOK, logs) }) - - router.POST(path, func(c *gin.Context) { - var log models.Log - if err := c.ShouldBindJSON(&log); err != nil { - c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()}) - return - } - db.Create(&log) - c.JSON(http.StatusCreated, log) - }) }