Files
Genarrative/server-rs/crates/api-server/src/modules/admin.rs
T
kdletters 25cac367c6 接入功能灰度与画布 Agent 灰度
新增 SpacetimeDB 灰度配置表与后端判定链路

新增后台灰度发布页面和两段式 Gate Key 选择器

将画布 Agent 入口接入灰度配置与运行时能力下发

修复灰度配置刷新读取空本地缓存的问题

补充灰度规则和后台下拉维护约定文档
2026-07-08 11:26:41 +08:00

236 lines
9.0 KiB
Rust

use axum::{
Router, middleware,
routing::{get, post},
};
use crate::{
admin::{
admin_create_editor_showcase_campaign_image_upload_ticket, admin_dashboard,
admin_debug_http, admin_get_creation_entry_config, 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_tracking_event_keys,
admin_list_tracking_events, admin_list_work_visibility, admin_login, admin_me,
admin_overview, admin_review_editor_showcase_asset,
admin_update_editor_showcase_asset_display, admin_update_work_visibility,
admin_upsert_creation_entry_config, admin_upsert_creation_entry_event_banners_config,
admin_upsert_editor_generation_pricing, admin_upsert_editor_showcase_campaign,
admin_upsert_feature_gate_config, admin_upsert_public_work_interaction_config,
require_admin_auth,
},
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/login", axum::routing::post(admin_login))
.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/creation-entry/config",
get(admin_get_creation_entry_config)
.post(admin_upsert_creation_entry_config)
.route_layer(middleware::from_fn_with_state(
state.clone(),
require_admin_auth,
)),
)
.route(
"/admin/api/creation-entry/config/banners",
post(admin_upsert_creation_entry_event_banners_config).route_layer(
middleware::from_fn_with_state(state.clone(), require_admin_auth),
),
)
.route(
"/admin/api/creation-entry/config/interactions",
post(admin_upsert_public_work_interaction_config).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/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/works/visibility",
get(admin_list_work_visibility)
.post(admin_update_work_visibility)
.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, require_admin_auth)),
)
}