187d7735b9
将模型定价改为 SpacetimeDB 强类型持久化并兼容旧配置种子迁移 修复快速编辑支付弹窗期间框选显示和交互冻结 补齐后台图片放大以及视频音频资源预览 收紧主站和 External 资源换签授权并记录管理员跨用户审计 固化外部生成入队价格、attempt 钱包结算和最终 lease 失败收口 加固运行时身份轮换、bootstrap secret 与生产构建发布门禁 同步生成绑定、定向测试、运维脚本和项目文档
243 lines
9.2 KiB
Rust
243 lines
9.2 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_asset_read_url, 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/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/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)),
|
|
)
|
|
}
|