This commit is contained in:
@@ -8,6 +8,7 @@ import (
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-contrib/sessions"
|
||||
"github.com/gin-contrib/slog"
|
||||
"github.com/gin-gonic/gin"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
@@ -58,6 +59,22 @@ func (handler *MediaLoFiHandler) Add(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, lofi)
|
||||
}
|
||||
|
||||
func (handler *MediaLoFiHandler) Update(c *gin.Context) {
|
||||
var input models.MediaLoFiDTO
|
||||
|
||||
if err := c.ShouldBindJSON(&input); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
lofi, err := handler.Service.Update(c.Request.Context(), input)
|
||||
if err != nil {
|
||||
logger := slog.Get(c)
|
||||
logger.Info("MediaLoFiHandler#Update", "error", err.Error())
|
||||
c.JSON(http.StatusNotFound, gin.H{"error": "lofi not updated"})
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, lofi)
|
||||
}
|
||||
func (handler *MediaLoFiHandler) Delete(c *gin.Context) {
|
||||
id := c.Param("id")
|
||||
err := handler.Service.Delete(c.Request.Context(), id)
|
||||
|
||||
Reference in New Issue
Block a user