Add a config to get inventaire.io URL
This commit is contained in:
@@ -15,6 +15,7 @@ type Config struct {
|
|||||||
JWTKey string `toml:"jwt_key" comment:"The key used to encrypt the generated JWT. Encoded in base64. If empty a random one will be generated on every restart."`
|
JWTKey string `toml:"jwt_key" comment:"The key used to encrypt the generated JWT. Encoded in base64. If empty a random one will be generated on every restart."`
|
||||||
ImageFolderPath string `toml:"image_folder_path" default:"img" comment:"Folder where uploaded files will be stored."`
|
ImageFolderPath string `toml:"image_folder_path" default:"img" comment:"Folder where uploaded files will be stored."`
|
||||||
Limit int `toml:"limit" default:"100" comment:"A single API call will return at most this number of records."`
|
Limit int `toml:"limit" default:"100" comment:"A single API call will return at most this number of records."`
|
||||||
|
InventaireUrl string `toml:"inventaire_url" default:"https://inventaire.io" comment:"An inventaire.io instance URL."`
|
||||||
}
|
}
|
||||||
|
|
||||||
func defaultConfig() Config {
|
func defaultConfig() Config {
|
||||||
@@ -25,6 +26,7 @@ func defaultConfig() Config {
|
|||||||
JWTKey: "",
|
JWTKey: "",
|
||||||
ImageFolderPath: "img",
|
ImageFolderPath: "img",
|
||||||
Limit: 100,
|
Limit: 100,
|
||||||
|
InventaireUrl: "https://inventaire.io",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,18 +18,14 @@ type InventaireSearchBook struct {
|
|||||||
Image string `json:"image"`
|
Image string `json:"image"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetBaseInventaireUrl() string {
|
func computeInventaireApiUrl(inventaireUrl string, paths ...string) (*url.URL, error) {
|
||||||
return "https://inventaire.io"
|
baseUrl := inventaireUrl + "/api"
|
||||||
}
|
|
||||||
|
|
||||||
func computeInventaireApiUrl(paths ...string) (*url.URL, error) {
|
|
||||||
baseUrl := GetBaseInventaireUrl() + "/api"
|
|
||||||
return callapiutils.ComputeUrl(baseUrl, paths...)
|
return callapiutils.ComputeUrl(baseUrl, paths...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func CallInventaireSearch(searchterm string, lang string, limit int, offset int) (InventaireSearchResult, error) {
|
func CallInventaireSearch(inventaireUrl string, searchterm string, lang string, limit int, offset int) (InventaireSearchResult, error) {
|
||||||
var queryResult InventaireSearchResult
|
var queryResult InventaireSearchResult
|
||||||
u, err := computeInventaireApiUrl("search")
|
u, err := computeInventaireApiUrl(inventaireUrl, "search")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return queryResult, err
|
return queryResult, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,8 +6,12 @@ import (
|
|||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func getBaseInventaireUrl() string {
|
||||||
|
return "https://inventaire.io"
|
||||||
|
}
|
||||||
|
|
||||||
func TestCallInventaireSearch_NoParameters(t *testing.T) {
|
func TestCallInventaireSearch_NoParameters(t *testing.T) {
|
||||||
result, err := CallInventaireSearch("salammbo", "", 0, 0)
|
result, err := CallInventaireSearch(getBaseInventaireUrl(), "salammbo", "", 0, 0)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
@@ -16,7 +20,7 @@ func TestCallInventaireSearch_NoParameters(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestCallInventaireSearch_NoLimit(t *testing.T) {
|
func TestCallInventaireSearch_NoLimit(t *testing.T) {
|
||||||
result, err := CallInventaireSearch("salammbo", "fr", 0, 0)
|
result, err := CallInventaireSearch(getBaseInventaireUrl(), "salammbo", "fr", 0, 0)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
@@ -25,7 +29,7 @@ func TestCallInventaireSearch_NoLimit(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestCallInventaireSearch_Limit(t *testing.T) {
|
func TestCallInventaireSearch_Limit(t *testing.T) {
|
||||||
result, err := CallInventaireSearch("salammbo", "fr", 5, 0)
|
result, err := CallInventaireSearch(getBaseInventaireUrl(), "salammbo", "fr", 5, 0)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
@@ -34,7 +38,7 @@ func TestCallInventaireSearch_Limit(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestCallInventaireSearch_Offset(t *testing.T) {
|
func TestCallInventaireSearch_Offset(t *testing.T) {
|
||||||
result, err := CallInventaireSearch("salammbo", "fr", 0, 15)
|
result, err := CallInventaireSearch(getBaseInventaireUrl(), "salammbo", "fr", 0, 15)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
@@ -43,7 +47,7 @@ func TestCallInventaireSearch_Offset(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestCallInventaireBook_BraveNewWorld(t *testing.T) {
|
func TestCallInventaireBook_BraveNewWorld(t *testing.T) {
|
||||||
result, err := callInventaireBook("wd:Q191949", "fr")
|
result, err := callInventaireBook(getBaseInventaireUrl(), "wd:Q191949", "fr")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
@@ -55,7 +59,7 @@ func TestCallInventaireBook_BraveNewWorld(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestCallInventaireEditionFromWork_TestLimit(t *testing.T) {
|
func TestCallInventaireEditionFromWork_TestLimit(t *testing.T) {
|
||||||
result, err := CallInventaireEditionFromWork("wd:Q339761", "fr", 10, 0)
|
result, err := CallInventaireEditionFromWork(getBaseInventaireUrl(), "wd:Q339761", "fr", 10, 0)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
@@ -64,7 +68,7 @@ func TestCallInventaireEditionFromWork_TestLimit(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestCallInventaireEditionFromWork_TestOffset(t *testing.T) {
|
func TestCallInventaireEditionFromWork_TestOffset(t *testing.T) {
|
||||||
result, err := CallInventaireEditionFromWork("wd:Q3213142", "fr", 0, 0)
|
result, err := CallInventaireEditionFromWork(getBaseInventaireUrl(), "wd:Q3213142", "fr", 0, 0)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
@@ -103,7 +107,7 @@ func TestCallInventaireEditionFromWork_TestOffset(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestCallInventaireEdition(t *testing.T) {
|
func TestCallInventaireEdition(t *testing.T) {
|
||||||
result, err := CallInventaireEdition("isbn:9782266003698", "fr")
|
result, err := CallInventaireEdition(getBaseInventaireUrl(), "isbn:9782266003698", "fr")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
@@ -127,7 +131,7 @@ func TestCallInventaireEdition(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestCallInventaireEditionFromISBN(t *testing.T) {
|
func TestCallInventaireEditionFromISBN(t *testing.T) {
|
||||||
result, err := CallInventaireFromISBN("9782070379248", "fr")
|
result, err := CallInventaireFromISBN(getBaseInventaireUrl(), "9782070379248", "fr")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -94,9 +94,9 @@ func findLangageField(multipleMessageFields map[string]json.RawMessage, lang str
|
|||||||
return parsedField, err
|
return parsedField, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func callInventaireBook(inventaireId string, lang string) (InventaireBookResult, error) {
|
func callInventaireBook(inventaireUrl string, inventaireId string, lang string) (InventaireBookResult, error) {
|
||||||
queryResult := InventaireBookResult{ID: inventaireId, Lang: lang}
|
queryResult := InventaireBookResult{ID: inventaireId, Lang: lang}
|
||||||
u, err := computeInventaireApiUrl("entities")
|
u, err := computeInventaireApiUrl(inventaireUrl, "entities")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return queryResult, err
|
return queryResult, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import (
|
|||||||
|
|
||||||
type inventaireEditionQueryResult struct {
|
type inventaireEditionQueryResult struct {
|
||||||
Entities []inventaireEditionQueryEntity
|
Entities []inventaireEditionQueryEntity
|
||||||
|
inventaireUrl string
|
||||||
}
|
}
|
||||||
|
|
||||||
type inventaireEditionQueryEntity struct {
|
type inventaireEditionQueryEntity struct {
|
||||||
@@ -75,7 +76,7 @@ func (i *inventaireEditionQueryResult) UnmarshalJSON(b []byte) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if image != "" {
|
if image != "" {
|
||||||
image = GetBaseInventaireUrl() + image
|
image = i.inventaireUrl + image
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
i.Entities = append(i.Entities, inventaireEditionQueryEntity{
|
i.Entities = append(i.Entities, inventaireEditionQueryEntity{
|
||||||
@@ -111,9 +112,9 @@ func parseStringArrayFieldInJsonRaw(jsonRawMap map[string]json.RawMessage, key s
|
|||||||
return s, err
|
return s, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func callInventaireEditionEntities(uris []string) (inventaireEditionQueryResult, error) {
|
func callInventaireEditionEntities(inventaireUrl string, uris []string) (inventaireEditionQueryResult, error) {
|
||||||
var queryResult inventaireEditionQueryResult
|
queryResult := inventaireEditionQueryResult{inventaireUrl: inventaireUrl}
|
||||||
u, err := getInventaireEditionEntitiesUri(strings.Join(uris, "|"))
|
u, err := getInventaireEditionEntitiesUri(inventaireUrl, strings.Join(uris, "|"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return queryResult, err
|
return queryResult, err
|
||||||
}
|
}
|
||||||
@@ -121,8 +122,8 @@ func callInventaireEditionEntities(uris []string) (inventaireEditionQueryResult,
|
|||||||
return queryResult, err
|
return queryResult, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func getInventaireEditionEntitiesUri(uris string) (*url.URL, error) {
|
func getInventaireEditionEntitiesUri(inventaireUrl string, uris string) (*url.URL, error) {
|
||||||
u, err := computeInventaireApiUrl("entities")
|
u, err := computeInventaireApiUrl(inventaireUrl, "entities")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return u, err
|
return u, err
|
||||||
}
|
}
|
||||||
@@ -162,9 +163,9 @@ func (i *inventaireEditionPublisherResult) UnmarshalJSON(b []byte) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func callInventairePublisherGetName(editionId string, lang string) (string, error) {
|
func callInventairePublisherGetName(inventaireUrl string, editionId string, lang string) (string, error) {
|
||||||
var queryResult inventaireEditionPublisherResult
|
var queryResult inventaireEditionPublisherResult
|
||||||
u, err := computeInventaireApiUrl("entities")
|
u, err := computeInventaireApiUrl(inventaireUrl, "entities")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,9 +26,9 @@ type inventaireReverseClaimsResult struct {
|
|||||||
Uris []string `json:"uris"`
|
Uris []string `json:"uris"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func CallInventaireEditionFromWork(workId string, lang string, limit int, offset int) (InventaireEditionResult, error) {
|
func CallInventaireEditionFromWork(inventaireUrl string, workId string, lang string, limit int, offset int) (InventaireEditionResult, error) {
|
||||||
var queryResult InventaireEditionResult
|
var queryResult InventaireEditionResult
|
||||||
uris, err := callInventaireUris(workId)
|
uris, err := callInventaireUris(inventaireUrl, workId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return queryResult, err
|
return queryResult, err
|
||||||
}
|
}
|
||||||
@@ -41,7 +41,7 @@ func CallInventaireEditionFromWork(workId string, lang string, limit int, offset
|
|||||||
endIndex := int(math.Min(float64(limit+offset), float64(l)))
|
endIndex := int(math.Min(float64(limit+offset), float64(l)))
|
||||||
limitedUris = uris.Uris[startIndex:endIndex]
|
limitedUris = uris.Uris[startIndex:endIndex]
|
||||||
}
|
}
|
||||||
editionEntities, err := callInventaireEditionEntities(limitedUris)
|
editionEntities, err := callInventaireEditionEntities(inventaireUrl, limitedUris)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return queryResult, err
|
return queryResult, err
|
||||||
@@ -55,7 +55,7 @@ func CallInventaireEditionFromWork(workId string, lang string, limit int, offset
|
|||||||
for _, entity := range sortedEntities {
|
for _, entity := range sortedEntities {
|
||||||
publisher := ""
|
publisher := ""
|
||||||
if entity.EditionId != "" {
|
if entity.EditionId != "" {
|
||||||
publisher, err = callInventairePublisherGetName(entity.EditionId, lang)
|
publisher, err = callInventairePublisherGetName(inventaireUrl, entity.EditionId, lang)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return queryResult, err
|
return queryResult, err
|
||||||
}
|
}
|
||||||
@@ -73,9 +73,9 @@ func CallInventaireEditionFromWork(workId string, lang string, limit int, offset
|
|||||||
return queryResult, err
|
return queryResult, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func callInventaireUris(workId string) (inventaireReverseClaimsResult, error) {
|
func callInventaireUris(inventaireUrl string, workId string) (inventaireReverseClaimsResult, error) {
|
||||||
var queryResult inventaireReverseClaimsResult
|
var queryResult inventaireReverseClaimsResult
|
||||||
u, err := computeInventaireApiUrl("entities")
|
u, err := computeInventaireApiUrl(inventaireUrl, "entities")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return queryResult, err
|
return queryResult, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,9 +24,9 @@ func (e *ErrorEditionNotFound) Error() string {
|
|||||||
return fmt.Sprintf("No edition found on inventaire for id %s\n", e.InventaireId)
|
return fmt.Sprintf("No edition found on inventaire for id %s\n", e.InventaireId)
|
||||||
}
|
}
|
||||||
|
|
||||||
func CallInventaireEdition(inventaireId string, lang string) (InventaireEditionDetailedSingleResult, error) {
|
func CallInventaireEdition(inventaireUrl string, inventaireId string, lang string) (InventaireEditionDetailedSingleResult, error) {
|
||||||
var result InventaireEditionDetailedSingleResult
|
var result InventaireEditionDetailedSingleResult
|
||||||
editionQueryResults, err := callInventaireEditionEntities([]string{inventaireId})
|
editionQueryResults, err := callInventaireEditionEntities(inventaireUrl, []string{inventaireId})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return result, err
|
return result, err
|
||||||
}
|
}
|
||||||
@@ -39,7 +39,7 @@ func CallInventaireEdition(inventaireId string, lang string) (InventaireEditionD
|
|||||||
|
|
||||||
var publisher string
|
var publisher string
|
||||||
if editionQueryResult.EditionId != "" {
|
if editionQueryResult.EditionId != "" {
|
||||||
publisher, err = callInventairePublisherGetName(editionQueryResult.EditionId, lang)
|
publisher, err = callInventairePublisherGetName(inventaireUrl, editionQueryResult.EditionId, lang)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return result, err
|
return result, err
|
||||||
}
|
}
|
||||||
@@ -48,7 +48,7 @@ func CallInventaireEdition(inventaireId string, lang string) (InventaireEditionD
|
|||||||
var author *InventaireAuthorResult
|
var author *InventaireAuthorResult
|
||||||
var description string
|
var description string
|
||||||
if editionQueryResult.WorkId != "" {
|
if editionQueryResult.WorkId != "" {
|
||||||
workQueryResult, err := callInventaireBook(editionQueryResult.WorkId, lang)
|
workQueryResult, err := callInventaireBook(inventaireUrl, editionQueryResult.WorkId, lang)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return result, err
|
return result, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ package inventaire
|
|||||||
|
|
||||||
import "errors"
|
import "errors"
|
||||||
|
|
||||||
func CallInventaireFromISBN(isbn string, lang string) (*InventaireEditionDetailedSingleResult, error) {
|
func CallInventaireFromISBN(inventaireUrl string, isbn string, lang string) (*InventaireEditionDetailedSingleResult, error) {
|
||||||
inventaireInfo, err := CallInventaireEdition("isbn:"+isbn, lang)
|
inventaireInfo, err := CallInventaireEdition(inventaireUrl, "isbn:"+isbn, lang)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if errors.Is(err, &ErrorEditionNotFound{}) {
|
if errors.Is(err, &ErrorEditionNotFound{}) {
|
||||||
//suppress the not found error, returns nil instead
|
//suppress the not found error, returns nil instead
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ func PostImportBookHandler(ac appcontext.AppContext) {
|
|||||||
myvalidator.ReturnErrorsAsJsonResponse(&ac, err)
|
myvalidator.ReturnErrorsAsJsonResponse(&ac, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
inventaireEdition, err := inventaire.CallInventaireEdition(request.InventaireID, request.Lang)
|
inventaireEdition, err := inventaire.CallInventaireEdition(ac.Config.InventaireUrl, request.InventaireID, request.Lang)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
myvalidator.ReturnErrorsAsJsonResponse(&ac, err)
|
myvalidator.ReturnErrorsAsJsonResponse(&ac, err)
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ func GetSearchBooksHandler(ac appcontext.AppContext) {
|
|||||||
returnedBooks = dto.BookSearchGet{Count: count, Inventaire: false, Books: books}
|
returnedBooks = dto.BookSearchGet{Count: count, Inventaire: false, Books: books}
|
||||||
}
|
}
|
||||||
if params.Inventaire || len(returnedBooks.Books) == 0 {
|
if params.Inventaire || len(returnedBooks.Books) == 0 {
|
||||||
returnedBooksPtr, err := searchInInventaireAPI(searchterm, limit, offset, params)
|
returnedBooksPtr, err := searchInInventaireAPI(ac.Config.InventaireUrl, searchterm, limit, offset, params)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
myvalidator.ReturnErrorsAsJsonResponse(&ac, err)
|
myvalidator.ReturnErrorsAsJsonResponse(&ac, err)
|
||||||
return
|
return
|
||||||
@@ -62,7 +62,7 @@ func GetSearchBooksHandler(ac appcontext.AppContext) {
|
|||||||
ac.C.JSON(http.StatusOK, returnedBooks)
|
ac.C.JSON(http.StatusOK, returnedBooks)
|
||||||
}
|
}
|
||||||
|
|
||||||
func searchInInventaireAPI(searchterm string, limit int, offset int, params dto.BookSearchGetParam) (*dto.BookSearchGet, error) {
|
func searchInInventaireAPI(inventaireUrl string, searchterm string, limit int, offset int, params dto.BookSearchGetParam) (*dto.BookSearchGet, error) {
|
||||||
|
|
||||||
isIsbn, err := regexp.Match(`\d{10,13}`, []byte(searchterm))
|
isIsbn, err := regexp.Match(`\d{10,13}`, []byte(searchterm))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -70,7 +70,7 @@ func searchInInventaireAPI(searchterm string, limit int, offset int, params dto.
|
|||||||
}
|
}
|
||||||
|
|
||||||
if isIsbn {
|
if isIsbn {
|
||||||
queryResult, err := inventaire.CallInventaireFromISBN(searchterm, params.Lang)
|
queryResult, err := inventaire.CallInventaireFromISBN(inventaireUrl, searchterm, params.Lang)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -82,11 +82,11 @@ func searchInInventaireAPI(searchterm string, limit int, offset int, params dto.
|
|||||||
}
|
}
|
||||||
return &bookSearchGet, err
|
return &bookSearchGet, err
|
||||||
} else {
|
} else {
|
||||||
queryResult, err := inventaire.CallInventaireSearch(searchterm, params.Lang, limit, offset)
|
queryResult, err := inventaire.CallInventaireSearch(inventaireUrl, searchterm, params.Lang, limit, offset)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
bookSearchGet := inventaireBooksToBookSearchGet(queryResult)
|
bookSearchGet := inventaireBooksToBookSearchGet(inventaireUrl, queryResult)
|
||||||
return &bookSearchGet, err
|
return &bookSearchGet, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -109,12 +109,12 @@ func inventaireEditionToBookSearchGet(result inventaire.InventaireEditionDetaile
|
|||||||
return dto.BookSearchGet{Count: 1, Inventaire: true, Books: books}
|
return dto.BookSearchGet{Count: 1, Inventaire: true, Books: books}
|
||||||
}
|
}
|
||||||
|
|
||||||
func inventaireBooksToBookSearchGet(results inventaire.InventaireSearchResult) dto.BookSearchGet {
|
func inventaireBooksToBookSearchGet(inventaireUrl string, results inventaire.InventaireSearchResult) dto.BookSearchGet {
|
||||||
var books []dto.BookSearchGetBook
|
var books []dto.BookSearchGetBook
|
||||||
for _, b := range results.Results {
|
for _, b := range results.Results {
|
||||||
coverPath := ""
|
coverPath := ""
|
||||||
if b.Image != "" && strings.HasPrefix(b.Image, "/") {
|
if b.Image != "" && strings.HasPrefix(b.Image, "/") {
|
||||||
coverPath = inventaire.GetBaseInventaireUrl() + b.Image
|
coverPath = inventaireUrl + b.Image
|
||||||
}
|
}
|
||||||
bookSearchGetBook := dto.BookSearchGetBook{
|
bookSearchGetBook := dto.BookSearchGetBook{
|
||||||
ID: 0,
|
ID: 0,
|
||||||
|
|||||||
@@ -28,8 +28,7 @@ func GetInventaireBooks(ac appcontext.AppContext) {
|
|||||||
myvalidator.ReturnErrorsAsJsonResponse(&ac, err)
|
myvalidator.ReturnErrorsAsJsonResponse(&ac, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
inventaireEditionResult, err := inventaire.CallInventaireEditionFromWork(ac.Config.InventaireUrl, workId, params.Lang, limit, offset)
|
||||||
inventaireEditionResult, err := inventaire.CallInventaireEditionFromWork(workId, params.Lang, limit, offset)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
myvalidator.ReturnErrorsAsJsonResponse(&ac, err)
|
myvalidator.ReturnErrorsAsJsonResponse(&ac, err)
|
||||||
return
|
return
|
||||||
|
|||||||
Reference in New Issue
Block a user