refactor(api): split Axum handlers into handler/service/repo modules

Keep the REST contract; move domain logic out of route files so checkout, fulfillment, and identity can be reused across customer, shop, and admin surfaces.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Chengdong Zhang
2026-09-18 14:59:36 +08:00
co-authored by Cursor
parent e457339847
commit 5e866d08f4
68 changed files with 3796 additions and 2304 deletions
+46
View File
@@ -22,3 +22,49 @@ pub fn convert_minor(amount_minor: i64, from: &Currency, to: &Currency) -> Resul
.to_i64()
.ok_or_else(|| ApiError::BadRequest("amount out of range".into()))
}
#[cfg(test)]
mod tests {
use super::*;
use rust_decimal_macros::dec;
fn usd() -> Currency {
Currency {
code: "USD".into(),
name: serde_json::json!({"en": "US Dollar"}),
symbol: "$".into(),
exponent: 2,
is_base: true,
rate_to_base: dec!(1),
enabled: true,
}
}
fn jpy() -> Currency {
Currency {
code: "JPY".into(),
name: serde_json::json!({"en": "Yen"}),
symbol: "¥".into(),
exponent: 0,
is_base: false,
rate_to_base: dec!(150),
enabled: true,
}
}
#[test]
fn same_currency_is_identity() {
assert_eq!(convert_minor(199, &usd(), &usd()).unwrap(), 199);
}
#[test]
fn rejects_negative() {
assert!(convert_minor(-1, &usd(), &usd()).is_err());
}
#[test]
fn converts_via_base_half_up() {
// 1.00 USD -> 150 JPY at rate 150
assert_eq!(convert_minor(100, &usd(), &jpy()).unwrap(), 150);
}
}