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