From bf2e1f2af640da2d9127bdc450c2b8f14e9d6052 Mon Sep 17 00:00:00 2001 From: brian Date: Mon, 22 Sep 2025 21:58:12 +0800 Subject: [PATCH] feat add http body --- src/model/http_body/book.rs | 2 +- src/model/http_body/category.rs | 7 +++++++ src/model/http_body/mod.rs | 3 ++- src/model/http_body/tag.rs | 2 +- src/model/http_body/transaction.rs | 21 +++++++++++++++++++++ 5 files changed, 32 insertions(+), 3 deletions(-) create mode 100644 src/model/http_body/transaction.rs diff --git a/src/model/http_body/book.rs b/src/model/http_body/book.rs index f37b201..d9f247c 100644 --- a/src/model/http_body/book.rs +++ b/src/model/http_body/book.rs @@ -2,7 +2,7 @@ use serde::{Serialize, Deserialize}; use super::common::{number_stringify, OptionalI64}; #[derive(Serialize)] -pub struct BookItem { +pub struct BookResp { #[serde(with="number_stringify")] pub id: OptionalI64, pub name: String, diff --git a/src/model/http_body/category.rs b/src/model/http_body/category.rs index cf2e8ea..c3a7f21 100644 --- a/src/model/http_body/category.rs +++ b/src/model/http_body/category.rs @@ -1,5 +1,12 @@ use serde::{Deserialize, Serialize}; use super::common::{number_stringify, OptionalI64}; +#[derive(Serialize, Deserialize)] +pub struct CategoryResp { + pub id: i64, + pub name: String, + pub parent_id: i64, +} + #[derive(Serialize, Deserialize)] pub struct CategoryInfo { #[serde(with="number_stringify")] diff --git a/src/model/http_body/mod.rs b/src/model/http_body/mod.rs index ef2967f..d339fbd 100644 --- a/src/model/http_body/mod.rs +++ b/src/model/http_body/mod.rs @@ -1,4 +1,5 @@ pub mod book; pub mod common; pub mod category; -pub mod tag; \ No newline at end of file +pub mod tag; +pub mod transaction; \ No newline at end of file diff --git a/src/model/http_body/tag.rs b/src/model/http_body/tag.rs index ab143e4..e584468 100644 --- a/src/model/http_body/tag.rs +++ b/src/model/http_body/tag.rs @@ -2,7 +2,7 @@ use serde::{Serialize, Deserialize}; use super::common::{number_stringify, OptionalI64}; #[derive(Serialize)] -pub struct TagItem { +pub struct TagResp { #[serde(with="number_stringify")] pub id: OptionalI64, pub name: String, diff --git a/src/model/http_body/transaction.rs b/src/model/http_body/transaction.rs new file mode 100644 index 0000000..a4c818a --- /dev/null +++ b/src/model/http_body/transaction.rs @@ -0,0 +1,21 @@ + use serde::{Serialize, Deserialize}; + use crate::model::http_body::tag::TagInfo; + use crate::model::http_body::category::CategoryResp; + use crate::model::http_body::common::OptionalI64; + + #[derive(Serialize,Deserialize)] + pub struct TransactionResp { + pub id: i64, + pub description: String, + pub category: CategoryResp, + pub tags: Vec, + } + + #[derive(Serialize,Deserialize)] + pub struct TransactionReq { + pub id: Option, + pub description: Option, + pub category_id: Option, + pub tags: Vec, + } +