feat(payments): 增加兑换码与支付适配框架 (#299)

* feat(payments): 增加兑换码与支付适配框架

* fix(ci): 对齐 Rust 1.95 lint 与格式要求

* fix(payments): harden redeem code wallet credits

---------

Co-authored-by: fawney19 <[email protected]>
This commit is contained in:
Entropy.Xu
2026-04-17 10:07:52 +08:00
committed by GitHub
co-authored by fawney19
parent 54d77598ae
commit 6964729cb7
36 changed files with 5129 additions and 274 deletions
@@ -510,6 +510,93 @@ pub(super) fn classify_admin_basic_family_route(
"admin:payments",
false,
))
} else if method == http::Method::GET
&& matches!(
normalized_path,
"/api/admin/payments/redeem-codes/batches"
| "/api/admin/payments/redeem-codes/batches/"
)
{
Some(classified(
"admin_proxy",
"payments_manage",
"list_redeem_code_batches",
"admin:payments",
false,
))
} else if method == http::Method::POST
&& matches!(
normalized_path,
"/api/admin/payments/redeem-codes/batches"
| "/api/admin/payments/redeem-codes/batches/"
)
{
Some(classified(
"admin_proxy",
"payments_manage",
"create_redeem_code_batch",
"admin:payments",
false,
))
} else if method == http::Method::GET
&& normalized_path_no_trailing.starts_with("/api/admin/payments/redeem-codes/batches/")
&& normalized_path_no_trailing.matches('/').count() == 6
{
Some(classified(
"admin_proxy",
"payments_manage",
"get_redeem_code_batch",
"admin:payments",
false,
))
} else if method == http::Method::GET
&& normalized_path_no_trailing.starts_with("/api/admin/payments/redeem-codes/batches/")
&& normalized_path_no_trailing.ends_with("/codes")
&& normalized_path_no_trailing.matches('/').count() == 7
{
Some(classified(
"admin_proxy",
"payments_manage",
"list_redeem_codes",
"admin:payments",
false,
))
} else if method == http::Method::POST
&& normalized_path_no_trailing.starts_with("/api/admin/payments/redeem-codes/batches/")
&& normalized_path_no_trailing.ends_with("/disable")
&& normalized_path_no_trailing.matches('/').count() == 7
{
Some(classified(
"admin_proxy",
"payments_manage",
"disable_redeem_code_batch",
"admin:payments",
false,
))
} else if method == http::Method::POST
&& normalized_path_no_trailing.starts_with("/api/admin/payments/redeem-codes/batches/")
&& normalized_path_no_trailing.ends_with("/delete")
&& normalized_path_no_trailing.matches('/').count() == 7
{
Some(classified(
"admin_proxy",
"payments_manage",
"delete_redeem_code_batch",
"admin:payments",
false,
))
} else if method == http::Method::POST
&& normalized_path_no_trailing.starts_with("/api/admin/payments/redeem-codes/codes/")
&& normalized_path_no_trailing.ends_with("/disable")
&& normalized_path_no_trailing.matches('/').count() == 7
{
Some(classified(
"admin_proxy",
"payments_manage",
"disable_redeem_code",
"admin:payments",
false,
))
} else {
None
}