diff --git a/internal/handlers/ebook.go b/internal/handlers/ebook.go index 61f450a..5269ae4 100644 --- a/internal/handlers/ebook.go +++ b/internal/handlers/ebook.go @@ -246,7 +246,7 @@ func (h *Handler) CreateEbook(c echo.Context) error { ebook, err := h.db.CreateEbook(c.Request().Context(), database.CreateEbookParams{ Title: req.Title, Author: pgtype.Text{String: req.Author, Valid: req.Author != ""}, - Isbn: pgtype.Text{String: req.ISBN, Valid: req.ISBN != ""}, + Isbn: req.ISBN, Description: pgtype.Text{String: req.Description, Valid: req.Description != ""}, FilePath: req.FilePath, FileSize: pgtype.Int8{Int64: req.FileSize, Valid: req.FileSize > 0}, @@ -305,7 +305,7 @@ func (h *Handler) UpdateEbook(c echo.Context) error { ID: pgtype.UUID{Bytes: id, Valid: true}, Title: req.Title, Author: pgtype.Text{String: req.Author, Valid: req.Author != ""}, - Isbn: pgtype.Text{String: req.ISBN, Valid: req.ISBN != ""}, + Isbn: req.ISBN, Description: pgtype.Text{String: req.Description, Valid: req.Description != ""}, CoverImagePath: pgtype.Text{String: req.CoverImagePath, Valid: req.CoverImagePath != ""}, Series: pgtype.Text{String: req.Series, Valid: req.Series != ""}, @@ -849,7 +849,7 @@ func (h *Handler) ListMediaItems(c echo.Context) error { return c.JSON(http.StatusInternalServerError, map[string]string{"error": err.Error()}) } - return c.JSON(http.StatusOK, items) + return c.JSON(http.StatusOK, map[string]interface{}{"data": items}) } items, err := h.db.ListMediaItems(c.Request().Context(), database.ListMediaItemsParams{ @@ -860,7 +860,7 @@ func (h *Handler) ListMediaItems(c echo.Context) error { return c.JSON(http.StatusInternalServerError, map[string]string{"error": err.Error()}) } - return c.JSON(http.StatusOK, items) + return c.JSON(http.StatusOK, map[string]interface{}{"data": items}) } // GetMediaItem handles GET /api/media-items/:id diff --git a/internal/handlers/library.go b/internal/handlers/library.go index 01ad375..9282fda 100644 --- a/internal/handlers/library.go +++ b/internal/handlers/library.go @@ -55,7 +55,7 @@ func (h *LibraryHandler) GetLibraryTypes(c echo.Context) error { // CreateLibrary creates a new library func (h *LibraryHandler) CreateLibrary(c echo.Context) error { - user := c.Get("user").(*database.Users) + user := c.Get("user").(database.Users) var req CreateLibraryRequest if err := c.Bind(&req); err != nil { @@ -101,12 +101,12 @@ func (h *LibraryHandler) ListLibraries(c echo.Context) error { return c.JSON(http.StatusInternalServerError, map[string]string{"error": err.Error()}) } - return c.JSON(http.StatusOK, libraries) + return c.JSON(http.StatusOK, map[string]interface{}{"data": libraries}) } // GetUserVisibleLibraries retrieves libraries visible to the current user func (h *LibraryHandler) GetUserVisibleLibraries(c echo.Context) error { - user := c.Get("user").(*database.Users) + user := c.Get("user").(database.Users) libraries, err := h.libraryService.GetUserVisibleLibraries(c.Request().Context(), user.ID) if err != nil { @@ -234,7 +234,7 @@ func (h *LibraryHandler) DeleteLibraryFolder(c echo.Context) error { // SetLibraryVisibility sets library visibility for a user func (h *LibraryHandler) SetLibraryVisibility(c echo.Context) error { - user := c.Get("user").(*database.Users) + user := c.Get("user").(database.Users) var req SetLibraryVisibilityRequest if err := c.Bind(&req); err != nil { diff --git a/internal/services/ebook_scanner.go b/internal/services/ebook_scanner.go index a6f87f0..fb22d7f 100644 --- a/internal/services/ebook_scanner.go +++ b/internal/services/ebook_scanner.go @@ -418,7 +418,7 @@ func (s *EbookScanner) updateEbook(ctx context.Context, ebookID pgtype.UUID, fil ID: ebookID, Title: metadata.Title, Author: pgtype.Text{String: metadata.Author, Valid: metadata.Author != ""}, - Isbn: pgtype.Text{String: metadata.ISBN, Valid: metadata.ISBN != ""}, + Isbn: metadata.ISBN, Description: pgtype.Text{String: metadata.Description, Valid: metadata.Description != ""}, CoverImagePath: pgtype.Text{String: metadata.CoverPath, Valid: metadata.CoverPath != ""}, Series: pgtype.Text{String: metadata.Series, Valid: metadata.Series != ""},