Inventaire API: display search image
This commit is contained in:
@@ -2,6 +2,7 @@ package routes
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"git.artlef.fr/PersonalLibraryManager/internal/appcontext"
|
||||
"git.artlef.fr/PersonalLibraryManager/internal/inventaire"
|
||||
@@ -44,14 +45,18 @@ func GetSearchBooksHandler(ac appcontext.AppContext) {
|
||||
myvalidator.ReturnErrorsAsJsonResponse(&ac, err)
|
||||
return
|
||||
}
|
||||
returnedBooks = OpenLibraryBooksToBookSearchGet(queryResult.Results)
|
||||
returnedBooks = InventaireBooksToBookSearchGet(queryResult.Results)
|
||||
}
|
||||
ac.C.JSON(http.StatusOK, returnedBooks)
|
||||
}
|
||||
|
||||
func OpenLibraryBooksToBookSearchGet(OLbooks []inventaire.InventaireSearchBook) []query.BookSearchGet {
|
||||
func InventaireBooksToBookSearchGet(inventairebooks []inventaire.InventaireSearchBook) []query.BookSearchGet {
|
||||
var books []query.BookSearchGet
|
||||
for _, b := range OLbooks {
|
||||
for _, b := range inventairebooks {
|
||||
coverPath := ""
|
||||
if b.Image != "" && strings.HasPrefix(b.Image, "/") {
|
||||
coverPath = inventaire.GetBaseInventaireUrl() + b.Image
|
||||
}
|
||||
bookSearchGet := query.BookSearchGet{
|
||||
ID: 0,
|
||||
Title: b.Label,
|
||||
@@ -60,7 +65,7 @@ func OpenLibraryBooksToBookSearchGet(OLbooks []inventaire.InventaireSearchBook)
|
||||
Rating: 0,
|
||||
Read: false,
|
||||
WantRead: false,
|
||||
CoverPath: "",
|
||||
CoverPath: coverPath,
|
||||
}
|
||||
books = append(books, bookSearchGet)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user