diff --git a/internal/handler/download_clients.go b/internal/handler/download_clients.go index 7c05286..0680c4e 100644 --- a/internal/handler/download_clients.go +++ b/internal/handler/download_clients.go @@ -75,7 +75,7 @@ func deleteDownloadClientHandler(svc *service.Container) gin.HandlerFunc { func testDownloadClientHandler(svc *service.Container) gin.HandlerFunc { return func(c *gin.Context) { if err := svc.DownloadClients.Test(c.Request.Context(), c.Param("id")); err != nil { - c.JSON(http.StatusBadRequest, gin.H{"ok": false, "error": err.Error()}) + c.JSON(http.StatusOK, gin.H{"ok": false, "error": err.Error()}) return } c.JSON(http.StatusOK, gin.H{"ok": true}) @@ -91,7 +91,7 @@ func aria2StatsHandler(svc *service.Container) gin.HandlerFunc { } out, err := svc.DownloadClients.Aria2GlobalStats(c.Request.Context(), clientID) if err != nil { - c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()}) + c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()}) return } c.JSON(http.StatusOK, out) diff --git a/internal/handler/organizer.go b/internal/handler/organizer.go index d4c7156..bd48a2b 100644 --- a/internal/handler/organizer.go +++ b/internal/handler/organizer.go @@ -13,7 +13,7 @@ func organizeMediaHandler(svc *service.Container) gin.HandlerFunc { return func(c *gin.Context) { dst, err := svc.Organizer.OrganizeMedia(c.Request.Context(), c.Param("id")) if err != nil { - c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()}) + c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()}) return } c.JSON(http.StatusOK, gin.H{"path": dst}) diff --git a/internal/handler/playback.go b/internal/handler/playback.go index 5b661c3..b3d99d9 100644 --- a/internal/handler/playback.go +++ b/internal/handler/playback.go @@ -109,10 +109,10 @@ func createPlaylistHandler(svc *service.Container) gin.HandlerFunc { c.Request.Context(), uid.(string), req.Name, req.IsPublic, ) if err != nil { - c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()}) + c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()}) return } - c.JSON(http.StatusOK, pl) + c.JSON(http.StatusCreated, pl) } } diff --git a/internal/handler/scheduler_handler.go b/internal/handler/scheduler_handler.go index 9e8f8d9..dccaaa5 100644 --- a/internal/handler/scheduler_handler.go +++ b/internal/handler/scheduler_handler.go @@ -33,7 +33,7 @@ func (h *SchedulerHandler) RunTask(c *gin.Context) { ctx := c.Request.Context() if err := h.svc.Scheduler.RunNow(ctx, name); err != nil { - Error(c, http.StatusBadRequest, ErrInternal, "任务执行失败: "+err.Error()) + Error(c, http.StatusInternalServerError, ErrInternal, "任务执行失败: "+err.Error()) return } diff --git a/internal/handler/sites.go b/internal/handler/sites.go index c22c262..9813ef0 100644 --- a/internal/handler/sites.go +++ b/internal/handler/sites.go @@ -99,7 +99,7 @@ func createSiteHandler(svc *service.Container) gin.HandlerFunc { Enabled: enabled, } if err := svc.Site.Create(c.Request.Context(), site); err != nil { - c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()}) + c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()}) return } c.JSON(http.StatusCreated, site) diff --git a/internal/handler/storage_config.go b/internal/handler/storage_config.go index 4ed94c0..9b937cb 100644 --- a/internal/handler/storage_config.go +++ b/internal/handler/storage_config.go @@ -50,7 +50,7 @@ func saveStorageConfigHandler(svc *service.Container) gin.HandlerFunc { in.Type = c.Param("type") row, err := svc.StorageCfg.Save(c.Request.Context(), in) if err != nil { - c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()}) + c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()}) return } c.JSON(http.StatusOK, row) @@ -67,7 +67,7 @@ func testStorageConfigHandler(svc *service.Container) gin.HandlerFunc { } in.Type = c.Param("type") if err := svc.StorageCfg.Test(c.Request.Context(), in); err != nil { - c.JSON(http.StatusBadRequest, gin.H{"ok": false, "error": err.Error()}) + c.JSON(http.StatusOK, gin.H{"ok": false, "error": err.Error()}) return } c.JSON(http.StatusOK, gin.H{"ok": true})