feat: book id use optional i64
This commit is contained in:
@@ -46,7 +46,7 @@ async fn get_all_books_handler(
|
||||
let mut books: Vec<BookItem> = Vec::new();
|
||||
for b in all_books {
|
||||
let book_resp = BookItem {
|
||||
id: b.id,
|
||||
id: b.id.into(),
|
||||
name: b.name,
|
||||
};
|
||||
books.push(book_resp);
|
||||
@@ -72,7 +72,7 @@ async fn get_book_by_id_handler(
|
||||
match book_query {
|
||||
Some(b) => {
|
||||
book_resp = BookItem {
|
||||
id: b.id,
|
||||
id: b.id.into(),
|
||||
name: b.name,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
use serde::{Serialize, Deserialize};
|
||||
use super::common::{number_stringify, OptionalI64};
|
||||
|
||||
#[derive(Serialize)]
|
||||
pub struct BookItem {
|
||||
pub id: i64,
|
||||
#[serde(with="number_stringify")]
|
||||
pub id: OptionalI64,
|
||||
pub name: String,
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user