Files
appks/api/workspace/mod.rs
T
zhenyi dca717be10 refactor(workspace): pass workspace object instead of id to service methods
- Replace workspace_id parameter with Workspace object reference in all workspace service methods
- Remove redundant find_workspace_by_id calls that were duplicated in each method
- Update all method signatures across approval, audit, billing, branding, core, settings and stats modules
- Modify SQL queries to bind ws.id instead of separate workspace_id parameter
- Add Workspace import to all affected modules
- Adjust method calls in API handlers to pass workspace object instead of id
- Consolidate workspace retrieval logic to single location per operation flow
2026-06-07 18:44:01 +08:00

212 lines
6.7 KiB
Rust

pub mod accept_invitation;
pub mod add_domain;
pub mod add_member;
pub mod archive;
pub mod audit_logs;
pub mod create;
pub mod create_integration;
pub mod create_invitation;
pub mod create_webhook;
pub mod delete;
pub mod delete_domain;
pub mod delete_integration;
pub mod delete_webhook;
pub mod get;
pub mod get_billing;
pub mod get_branding;
pub mod get_settings;
pub mod get_stats;
pub mod leave;
pub mod list;
pub mod list_approvals;
pub mod list_domains;
pub mod list_integrations;
pub mod list_invitations;
pub mod list_members;
pub mod list_webhooks;
pub mod refresh_stats;
pub mod remove_member;
pub mod request_approval;
pub mod review_approval;
pub mod revoke_invitation;
pub mod set_primary_domain;
pub mod transfer_owner;
pub mod unarchive;
pub mod update;
pub mod update_billing;
pub mod update_branding;
pub mod update_integration;
pub mod update_member_role;
pub mod update_settings;
pub mod update_webhook;
pub mod upload_avatar;
pub mod verify_domain;
use actix_web::web;
pub fn configure(cfg: &mut web::ServiceConfig) {
cfg.service(
web::scope("/workspaces")
// Core
.route("", web::get().to(list::handle))
.route("", web::post().to(create::handle))
.route(
"/invitations/accept",
web::post().to(accept_invitation::handle),
)
.route("/{workspace_name}", web::get().to(get::handle))
.route("/{workspace_name}", web::put().to(update::handle))
.route("/{workspace_name}", web::delete().to(delete::handle))
.route("/{workspace_name}/archive", web::post().to(archive::handle))
.route(
"/{workspace_name}/unarchive",
web::post().to(unarchive::handle),
)
.route(
"/{workspace_name}/transfer-owner",
web::post().to(transfer_owner::handle),
)
.route(
"/{workspace_name}/avatar",
web::post().to(upload_avatar::handle),
)
// Members
.route(
"/{workspace_name}/members",
web::get().to(list_members::handle),
)
.route(
"/{workspace_name}/members",
web::post().to(add_member::handle),
)
.route(
"/{workspace_name}/members/{member_id}/role",
web::put().to(update_member_role::handle),
)
.route(
"/{workspace_name}/members/{member_id}",
web::delete().to(remove_member::handle),
)
.route("/{workspace_name}/leave", web::post().to(leave::handle))
// Invitations
.route(
"/{workspace_name}/invitations",
web::get().to(list_invitations::handle),
)
.route(
"/{workspace_name}/invitations",
web::post().to(create_invitation::handle),
)
.route(
"/{workspace_name}/invitations/{invitation_id}",
web::delete().to(revoke_invitation::handle),
)
// Billing
.route(
"/{workspace_name}/billing",
web::get().to(get_billing::handle),
)
.route(
"/{workspace_name}/billing",
web::put().to(update_billing::handle),
)
// Branding
.route(
"/{workspace_name}/branding",
web::get().to(get_branding::handle),
)
.route(
"/{workspace_name}/branding",
web::put().to(update_branding::handle),
)
// Settings
.route(
"/{workspace_name}/settings",
web::get().to(get_settings::handle),
)
.route(
"/{workspace_name}/settings",
web::put().to(update_settings::handle),
)
// Stats
.route("/{workspace_name}/stats", web::get().to(get_stats::handle))
.route(
"/{workspace_name}/stats/refresh",
web::post().to(refresh_stats::handle),
)
// Integrations
.route(
"/{workspace_name}/integrations",
web::get().to(list_integrations::handle),
)
.route(
"/{workspace_name}/integrations",
web::post().to(create_integration::handle),
)
.route(
"/{workspace_name}/integrations/{integration_id}",
web::put().to(update_integration::handle),
)
.route(
"/{workspace_name}/integrations/{integration_id}",
web::delete().to(delete_integration::handle),
)
// Webhooks
.route(
"/{workspace_name}/webhooks",
web::get().to(list_webhooks::handle),
)
.route(
"/{workspace_name}/webhooks",
web::post().to(create_webhook::handle),
)
.route(
"/{workspace_name}/webhooks/{webhook_id}",
web::put().to(update_webhook::handle),
)
.route(
"/{workspace_name}/webhooks/{webhook_id}",
web::delete().to(delete_webhook::handle),
)
// Domains
.route(
"/{workspace_name}/domains",
web::get().to(list_domains::handle),
)
.route(
"/{workspace_name}/domains",
web::post().to(add_domain::handle),
)
.route(
"/{workspace_name}/domains/{domain_id}/verify",
web::post().to(verify_domain::handle),
)
.route(
"/{workspace_name}/domains/{domain_id}/primary",
web::put().to(set_primary_domain::handle),
)
.route(
"/{workspace_name}/domains/{domain_id}",
web::delete().to(delete_domain::handle),
)
// Approvals
.route(
"/{workspace_name}/approvals",
web::get().to(list_approvals::handle),
)
.route(
"/{workspace_name}/approvals",
web::post().to(request_approval::handle),
)
.route(
"/{workspace_name}/approvals/{approval_id}",
web::put().to(review_approval::handle),
)
// Audit
.route(
"/{workspace_name}/audit-logs",
web::get().to(audit_logs::handle),
),
);
}