fix: correct type assertions and ISBN type mismatches
- Fix type assertion panics in library.go (lines 58, 109, 237) Changed from *database.Users to database.Users to match JWT middleware - Fix ISBN type mismatch in ebook.go (lines 249, 308) Changed from pgtype.Text to string to match database schema - Fix ISBN type mismatch in ebook_scanner.go (line 421) Changed from pgtype.Text to string to match database schema These changes fix 500 errors in library creation and ebook operations.
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user