v0.15-WORKINGV1
This commit is contained in:
@@ -30,6 +30,7 @@ use meilisearch_sdk::client::Client;
|
||||
use ::entity::entities::{book,book_author,book_person,book_place,book_subject,book_time,book_isbn};
|
||||
use std::env;
|
||||
use migration::{Migrator, MigratorTrait};
|
||||
use chrono::Local;
|
||||
|
||||
#[derive(Deserialize, Serialize, Debug, Clone)]
|
||||
struct BookUI {
|
||||
@@ -605,7 +606,7 @@ async fn list_search_book(
|
||||
|
||||
let mut resbooks: Vec<BookUI> = Vec::with_capacity(24);
|
||||
|
||||
for bookmeili in books.into_iter() {
|
||||
for bookmeili in books.0.into_iter() {
|
||||
let mut cover = bookmeili.clone().cover;
|
||||
if cover!="".to_string() {
|
||||
cover = format!("{}/images/{}",backend_url,cover);
|
||||
@@ -637,7 +638,7 @@ let mut resbooks: Vec<BookUI> = Vec::with_capacity(24);
|
||||
}
|
||||
|
||||
let res = PaginatedBookUIList{
|
||||
num_pages: 10,
|
||||
num_pages: (books.1/24) as u32,
|
||||
books: resbooks
|
||||
};
|
||||
return Json(res);
|
||||
@@ -668,7 +669,7 @@ async fn create_book(
|
||||
let img_bytes = reqwest::get(cover.unwrap()).await.unwrap().bytes().await.unwrap();
|
||||
let image = image::load_from_memory(&img_bytes).unwrap();
|
||||
let temp_cover = doc_sent.cover.clone().unwrap();
|
||||
let img_id = temp_cover.split("/").last().unwrap();
|
||||
let img_id = format!("{}{}",temp_cover.split("/").last().unwrap(),Local::now().format("%Y-%m-%d-%H-%M-%S"));
|
||||
image.save(format!("{}/{}",images_dir,img_id)).expect("Failed to save image");
|
||||
cover = Some(img_id.to_string());
|
||||
}
|
||||
@@ -766,7 +767,7 @@ async fn create_book(
|
||||
median_page_count: doc_sent.median_page_count.unwrap_or(0),
|
||||
goodread_id: doc_sent.goodread_id.unwrap_or("".to_string()),
|
||||
description: doc_sent.description.unwrap_or("".to_string()),
|
||||
cover: doc_sent.cover.unwrap_or("".to_string()),
|
||||
cover: cover.unwrap_or("".to_string()),
|
||||
location: doc_sent.location.unwrap_or("".to_string()),
|
||||
time_added: doc_sent.time_added.unwrap_or("".to_string()),
|
||||
rating: doc_sent.rating.unwrap_or(0),
|
||||
@@ -807,7 +808,7 @@ if !doc_sent.cover.is_none() {
|
||||
//let img_bytes = img_resp.unwrap().bytes();
|
||||
let image = image::load_from_memory(&img_bytes).unwrap();
|
||||
let temp_cover = doc_sent.cover.clone().unwrap();
|
||||
let img_id = temp_cover.split("/").last().unwrap();
|
||||
let img_id = format!("{}{}",temp_cover.split("/").last().unwrap(),Local::now().format("%Y-%m-%d-%H-%M-%S"));
|
||||
image.save(format!("{}/{}",images_dir,img_id)).expect("Failed to save image");
|
||||
cover = Some(img_id.to_string());
|
||||
}
|
||||
@@ -929,7 +930,7 @@ let book: book::Model = book::Model{
|
||||
median_page_count: doc_sent.median_page_count.unwrap_or(0),
|
||||
goodread_id: doc_sent.goodread_id.unwrap_or("".to_string()),
|
||||
description: doc_sent.description.unwrap_or("".to_string()),
|
||||
cover: doc_sent.cover.unwrap_or("".to_string()),
|
||||
cover: cover.unwrap_or("".to_string()),
|
||||
location: doc_sent.location.unwrap_or("".to_string()),
|
||||
time_added: doc_sent.time_added.unwrap_or("".to_string()),
|
||||
rating: doc_sent.rating.unwrap_or(0),
|
||||
|
||||
Reference in New Issue
Block a user