feat(bill): 初始化账单服务模块

- 创建账单服务模块并配置路由
- 实现银行卡数据的增删查功能
- 添加日志记录中间件支持
- 更新工作区依赖配置
- 修改HTTP请求示例文件
This commit is contained in:
hz
2025-12-05 11:28:25 +08:00
parent 1eee628b79
commit 770e84d53b
8 changed files with 62 additions and 14 deletions

12
packages/bill/Cargo.toml Normal file
View File

@@ -0,0 +1,12 @@
[package]
name = "bill"
version = "0.1.0"
edition = "2024"
[dependencies]
actix-web.workspace = true
serde.workspace = true
serde_json.workspace = true
tokio.workspace = true
hutils.workspace = true
log = "0.4.28"

View File

@@ -0,0 +1,8 @@
### 请求 card 数据
GET http://localhost:8080/bank-card
### 添加 card 数据
POST http://localhost:8080/bank-card
### 删除 card 数据
DELETE http://localhost:8080/bank-card

19
packages/bill/src/main.rs Normal file
View File

@@ -0,0 +1,19 @@
mod router;
use actix_web::middleware::Logger;
use actix_web::{App, HttpServer, main};
use hutils::logger::init_logger;
#[main]
async fn main() -> std::io::Result<()> {
init_logger();
HttpServer::new(move || {
let app = App::new();
let app = app.configure(router::router_register);
let app = app.wrap(Logger::default());
app
})
.bind("0.0.0.0:8080")?
.run()
.await
}

View File

@@ -0,0 +1,25 @@
use actix_web::{delete, get, post, web};
use log::info;
pub fn bank_card_router_configure(cfg: &mut web::ServiceConfig) {
cfg
.service(get_bank_card)
.service(post_bank_card)
.service(delete_bank_card);
}
#[get("/bank-card")]
pub async fn get_bank_card() -> String {
info!("this is get bank card");
String::from("Bill Get")
}
#[post("/bank-card")]
pub async fn post_bank_card() -> String {
info!("this is post bank card");
String::from("Bill Post")
}
#[delete("/bank-card")]
pub async fn delete_bank_card() -> String {
info!("this is delete bank card");
String::from("Bill Delete")
}

View File

@@ -0,0 +1,5 @@
pub mod bank_card;
use actix_web::web;
pub fn router_register(cfg: &mut web::ServiceConfig) {
cfg.configure(bank_card::bank_card_router_configure);
}