4f3f0f24ff
新增后台 AGC 模型目录、别名、启停和默认项管理 客户端设置页恢复原状,对话框右下角按别名选择模型 服务端按稳定模型标识映射并校验实际模型白名单 修复 AGC 配套后端端口漂移、启动等待和 SpacetimeDB 版本检查 补充迁移、文档、启动与模型选择测试
320 lines
12 KiB
Rust
320 lines
12 KiB
Rust
use axum::{
|
|
Router, middleware,
|
|
routing::{get, post},
|
|
};
|
|
|
|
use crate::{
|
|
admin::{
|
|
admin_confirm_editor_showcase_campaign_image_upload,
|
|
admin_create_editor_showcase_campaign_image_upload_ticket, admin_dashboard,
|
|
admin_debug_http, admin_get_asset_read_url, admin_get_editor_generation_pricing,
|
|
admin_get_editor_showcase_campaign, admin_get_feature_gate_config,
|
|
admin_list_database_table_rows, admin_list_database_tables, admin_list_editor_assets,
|
|
admin_list_editor_showcase_assets, admin_list_external_api_keys,
|
|
admin_list_tracking_event_keys, admin_list_tracking_events, admin_login, admin_me,
|
|
admin_overview, admin_review_editor_showcase_asset,
|
|
admin_update_editor_showcase_asset_display, admin_upsert_editor_generation_pricing,
|
|
admin_upsert_editor_showcase_campaign, admin_upsert_feature_gate_config,
|
|
require_admin_auth,
|
|
},
|
|
admin_accounts::{admin_create_account, admin_list_accounts, admin_update_account},
|
|
admin_recharge::{
|
|
admin_execute_recharge_refund, admin_get_user_detail,
|
|
admin_initialize_user_consumption_projections, admin_list_recharge_orders,
|
|
admin_preview_recharge_refund, admin_reconcile_user_consumption,
|
|
admin_register_recharge_refund, admin_resolve_recharge_refund_manual_review,
|
|
admin_update_wallet_restriction,
|
|
},
|
|
runtime_profile::{
|
|
admin_disable_profile_redeem_code, admin_disable_profile_task_config,
|
|
admin_get_profile_wallet_config, admin_list_profile_invite_codes,
|
|
admin_list_profile_recharge_products, admin_list_profile_redeem_codes,
|
|
admin_list_profile_task_configs, admin_upsert_profile_invite_code,
|
|
admin_upsert_profile_recharge_product, admin_upsert_profile_redeem_code,
|
|
admin_upsert_profile_task_config, admin_upsert_profile_wallet_config,
|
|
},
|
|
state::AppState,
|
|
};
|
|
|
|
pub fn router(state: AppState) -> Router<AppState> {
|
|
Router::new()
|
|
.route(
|
|
"/admin/api/agc-models",
|
|
get(crate::agc_models::admin_get_agc_models)
|
|
.put(crate::agc_models::admin_save_agc_models)
|
|
.route_layer(middleware::from_fn_with_state(
|
|
state.clone(),
|
|
require_admin_auth,
|
|
)),
|
|
)
|
|
.route("/admin/api/login", axum::routing::post(admin_login))
|
|
.route(
|
|
"/admin/api/accounts",
|
|
get(admin_list_accounts)
|
|
.post(admin_create_account)
|
|
.route_layer(middleware::from_fn_with_state(
|
|
state.clone(),
|
|
require_admin_auth,
|
|
)),
|
|
)
|
|
.route(
|
|
"/admin/api/accounts/{account_id}",
|
|
axum::routing::put(admin_update_account).route_layer(middleware::from_fn_with_state(
|
|
state.clone(),
|
|
require_admin_auth,
|
|
)),
|
|
)
|
|
.route(
|
|
"/admin/api/me",
|
|
get(admin_me).route_layer(middleware::from_fn_with_state(
|
|
state.clone(),
|
|
require_admin_auth,
|
|
)),
|
|
)
|
|
.route(
|
|
"/admin/api/overview",
|
|
get(admin_overview).route_layer(middleware::from_fn_with_state(
|
|
state.clone(),
|
|
require_admin_auth,
|
|
)),
|
|
)
|
|
.route(
|
|
"/admin/api/dashboard",
|
|
get(admin_dashboard).route_layer(middleware::from_fn_with_state(
|
|
state.clone(),
|
|
require_admin_auth,
|
|
)),
|
|
)
|
|
.route(
|
|
"/admin/api/debug/http",
|
|
axum::routing::post(admin_debug_http).route_layer(middleware::from_fn_with_state(
|
|
state.clone(),
|
|
require_admin_auth,
|
|
)),
|
|
)
|
|
.route(
|
|
"/admin/api/tracking/events",
|
|
get(admin_list_tracking_events).route_layer(middleware::from_fn_with_state(
|
|
state.clone(),
|
|
require_admin_auth,
|
|
)),
|
|
)
|
|
.route(
|
|
"/admin/api/tracking/event-keys",
|
|
get(admin_list_tracking_event_keys).route_layer(middleware::from_fn_with_state(
|
|
state.clone(),
|
|
require_admin_auth,
|
|
)),
|
|
)
|
|
.route(
|
|
"/admin/api/database/tables",
|
|
get(admin_list_database_tables).route_layer(middleware::from_fn_with_state(
|
|
state.clone(),
|
|
require_admin_auth,
|
|
)),
|
|
)
|
|
.route(
|
|
"/admin/api/database/tables/{table_name}/rows",
|
|
get(admin_list_database_table_rows).route_layer(middleware::from_fn_with_state(
|
|
state.clone(),
|
|
require_admin_auth,
|
|
)),
|
|
)
|
|
.route(
|
|
"/admin/api/external-api-keys",
|
|
get(admin_list_external_api_keys).route_layer(middleware::from_fn_with_state(
|
|
state.clone(),
|
|
require_admin_auth,
|
|
)),
|
|
)
|
|
.route(
|
|
"/admin/api/feature-gates",
|
|
get(admin_get_feature_gate_config)
|
|
.put(admin_upsert_feature_gate_config)
|
|
.route_layer(middleware::from_fn_with_state(
|
|
state.clone(),
|
|
require_admin_auth,
|
|
)),
|
|
)
|
|
.route(
|
|
"/admin/api/editor-generation-pricing",
|
|
get(admin_get_editor_generation_pricing)
|
|
.post(admin_upsert_editor_generation_pricing)
|
|
.route_layer(middleware::from_fn_with_state(
|
|
state.clone(),
|
|
require_admin_auth,
|
|
)),
|
|
)
|
|
.route(
|
|
"/admin/api/editor-assets",
|
|
get(admin_list_editor_assets).route_layer(middleware::from_fn_with_state(
|
|
state.clone(),
|
|
require_admin_auth,
|
|
)),
|
|
)
|
|
.route(
|
|
"/admin/api/assets/read-url",
|
|
get(admin_get_asset_read_url).route_layer(middleware::from_fn_with_state(
|
|
state.clone(),
|
|
require_admin_auth,
|
|
)),
|
|
)
|
|
.route(
|
|
"/admin/api/editor-showcase/assets",
|
|
get(admin_list_editor_showcase_assets).route_layer(middleware::from_fn_with_state(
|
|
state.clone(),
|
|
require_admin_auth,
|
|
)),
|
|
)
|
|
.route(
|
|
"/admin/api/editor-showcase/assets/review",
|
|
post(admin_review_editor_showcase_asset).route_layer(middleware::from_fn_with_state(
|
|
state.clone(),
|
|
require_admin_auth,
|
|
)),
|
|
)
|
|
.route(
|
|
"/admin/api/editor-showcase/assets/display",
|
|
post(admin_update_editor_showcase_asset_display).route_layer(
|
|
middleware::from_fn_with_state(state.clone(), require_admin_auth),
|
|
),
|
|
)
|
|
.route(
|
|
"/admin/api/editor-showcase/campaign",
|
|
get(admin_get_editor_showcase_campaign)
|
|
.post(admin_upsert_editor_showcase_campaign)
|
|
.route_layer(middleware::from_fn_with_state(
|
|
state.clone(),
|
|
require_admin_auth,
|
|
)),
|
|
)
|
|
.route(
|
|
"/admin/api/editor-showcase/campaign/image-upload-ticket",
|
|
post(admin_create_editor_showcase_campaign_image_upload_ticket).route_layer(
|
|
middleware::from_fn_with_state(state.clone(), require_admin_auth),
|
|
),
|
|
)
|
|
.route(
|
|
"/admin/api/editor-showcase/campaign/image-upload-confirm",
|
|
post(admin_confirm_editor_showcase_campaign_image_upload).route_layer(
|
|
middleware::from_fn_with_state(state.clone(), require_admin_auth),
|
|
),
|
|
)
|
|
.route(
|
|
"/admin/api/profile/redeem-codes",
|
|
get(admin_list_profile_redeem_codes)
|
|
.post(admin_upsert_profile_redeem_code)
|
|
.route_layer(middleware::from_fn_with_state(
|
|
state.clone(),
|
|
require_admin_auth,
|
|
)),
|
|
)
|
|
.route(
|
|
"/admin/api/profile/redeem-codes/disable",
|
|
axum::routing::post(admin_disable_profile_redeem_code).route_layer(
|
|
middleware::from_fn_with_state(state.clone(), require_admin_auth),
|
|
),
|
|
)
|
|
.route(
|
|
"/admin/api/profile/invite-codes",
|
|
get(admin_list_profile_invite_codes)
|
|
.post(admin_upsert_profile_invite_code)
|
|
.route_layer(middleware::from_fn_with_state(
|
|
state.clone(),
|
|
require_admin_auth,
|
|
)),
|
|
)
|
|
.route(
|
|
"/admin/api/profile/tasks",
|
|
get(admin_list_profile_task_configs)
|
|
.post(admin_upsert_profile_task_config)
|
|
.route_layer(middleware::from_fn_with_state(
|
|
state.clone(),
|
|
require_admin_auth,
|
|
)),
|
|
)
|
|
.route(
|
|
"/admin/api/profile/tasks/disable",
|
|
axum::routing::post(admin_disable_profile_task_config).route_layer(
|
|
middleware::from_fn_with_state(state.clone(), require_admin_auth),
|
|
),
|
|
)
|
|
.route(
|
|
"/admin/api/profile/wallet-config",
|
|
get(admin_get_profile_wallet_config)
|
|
.post(admin_upsert_profile_wallet_config)
|
|
.route_layer(middleware::from_fn_with_state(
|
|
state.clone(),
|
|
require_admin_auth,
|
|
)),
|
|
)
|
|
.route(
|
|
"/admin/api/profile/recharge-products",
|
|
get(admin_list_profile_recharge_products)
|
|
.post(admin_upsert_profile_recharge_product)
|
|
.route_layer(middleware::from_fn_with_state(
|
|
state.clone(),
|
|
require_admin_auth,
|
|
)),
|
|
)
|
|
.route(
|
|
"/admin/api/profile/recharge-orders",
|
|
get(admin_list_recharge_orders).route_layer(middleware::from_fn_with_state(
|
|
state.clone(),
|
|
require_admin_auth,
|
|
)),
|
|
)
|
|
.route(
|
|
"/admin/api/profile/recharge-refunds/preview",
|
|
post(admin_preview_recharge_refund).route_layer(middleware::from_fn_with_state(
|
|
state.clone(),
|
|
require_admin_auth,
|
|
)),
|
|
)
|
|
.route(
|
|
"/admin/api/profile/recharge-refunds/execute",
|
|
post(admin_execute_recharge_refund).route_layer(middleware::from_fn_with_state(
|
|
state.clone(),
|
|
require_admin_auth,
|
|
)),
|
|
)
|
|
.route(
|
|
"/admin/api/profile/recharge-refunds/register",
|
|
post(admin_register_recharge_refund).route_layer(middleware::from_fn_with_state(
|
|
state.clone(),
|
|
require_admin_auth,
|
|
)),
|
|
)
|
|
.route(
|
|
"/admin/api/profile/recharge-refunds/manual-review/resolve",
|
|
post(admin_resolve_recharge_refund_manual_review).route_layer(
|
|
middleware::from_fn_with_state(state.clone(), require_admin_auth),
|
|
),
|
|
)
|
|
.route(
|
|
"/admin/api/profile/users/detail",
|
|
get(admin_get_user_detail).route_layer(middleware::from_fn_with_state(
|
|
state.clone(),
|
|
require_admin_auth,
|
|
)),
|
|
)
|
|
.route(
|
|
"/admin/api/profile/users/reconcile-consumption",
|
|
post(admin_reconcile_user_consumption).route_layer(middleware::from_fn_with_state(
|
|
state.clone(),
|
|
require_admin_auth,
|
|
)),
|
|
)
|
|
.route(
|
|
"/admin/api/profile/users/initialize-consumption-projections",
|
|
post(admin_initialize_user_consumption_projections).route_layer(
|
|
middleware::from_fn_with_state(state.clone(), require_admin_auth),
|
|
),
|
|
)
|
|
.route(
|
|
"/admin/api/profile/wallet-restriction",
|
|
post(admin_update_wallet_restriction)
|
|
.route_layer(middleware::from_fn_with_state(state, require_admin_auth)),
|
|
)
|
|
}
|