replace OpenLibrary calls with BNF calls

This commit is contained in:
Ninjdai 2025-08-04 13:17:05 +02:00
parent fc494d2135
commit 3320d1400c

View file

@ -6,7 +6,7 @@ use sea_orm::{ActiveModelTrait, ActiveValue::{NotSet, Set}, ColumnTrait, EntityT
use serde::{Deserialize, Serialize};
use utoipa::IntoParams;
use crate::{entities::{book, prelude::{Book}}, utils::open_library};
use crate::{entities::{book, prelude::Book}, utils::{bnf}};
use crate::AppState;
@ -72,7 +72,7 @@ pub async fn get_book_by_ean(
if let Ok(Some(res)) = Book::find().filter(book::Column::Ean.eq(&ean)).one(state.db_conn.as_ref()).await {
(StatusCode::OK, Json(Some(res)))
} else {
let fetched_book = open_library::fetch_book_by_ean(&state.web_client, &ean).await;
let fetched_book = bnf::fetch_book_by_ean(&state.web_client, &ean).await;
if let Some(book) = fetched_book {
let res = Book::insert(book.to_active_model()).exec(state.db_conn.as_ref()).await.unwrap();
(StatusCode::OK, Json(Some(book::Model {