pub mod group;
pub mod join;
pub mod member;
pub mod workspace;

use actix_web::{web, web::ServiceConfig};
pub fn configure(cfg: &mut ServiceConfig) {
    cfg.service(
        web::resource("").route(web::post().to(workspace::create_workspace)),
    );
    cfg.service(
        web::resource("/my").route(web::get().to(workspace::my_workspaces)),
    );
    cfg.service(
        web::resource("/join/my-applies")
            .route(web::get().to(join::my_join_applies)),
    );
}
pub fn configure_wk(cfg: &mut ServiceConfig) {
    cfg.service(
        web::resource("")
            .route(web::get().to(workspace::get_workspace))
            .route(web::put().to(workspace::update_workspace)),
    );
    cfg.service(
        web::resource("/avatar")
            .route(web::get().to(workspace::get_avatar))
            .route(web::post().to(workspace::upload_avatar)),
    );
    cfg.service(
        web::resource("/members")
            .route(web::get().to(member::list_members))
            .route(web::post().to(member::add_member)),
    );
    cfg.service(
        web::resource("/members/{username}")
            .route(web::put().to(member::update_member))
            .route(web::delete().to(member::remove_member)),
    );
    cfg.service(
        web::resource("/groups")
            .route(web::get().to(group::list_groups))
            .route(web::post().to(group::create_group)),
    );
    cfg.service(
        web::resource("/groups/{group_name}")
            .route(web::put().to(group::update_group))
            .route(web::delete().to(group::delete_group)),
    );
    cfg.service(
        web::resource("/groups/{group_name}/members/{username}")
            .route(web::post().to(group::add_group_member))
            .route(web::delete().to(group::remove_group_member)),
    );
    cfg.service(
        web::resource("/groups/{group_name}/members")
            .route(web::get().to(group::list_group_members)),
    );
    cfg.service(
        web::resource("/join-strategy")
            .route(web::get().to(join::join_strategy))
            .route(web::put().to(join::update_join_strategy)),
    );
    cfg.service(
        web::resource("/join/apply").route(web::post().to(join::apply_join)),
    );
    cfg.service(
        web::resource("/join/cancel").route(web::post().to(join::cancel_join)),
    );
    cfg.service(
        web::resource("/join/applies")
            .route(web::get().to(join::list_join_applies)),
    );
    cfg.service(
        web::resource("/join/applies/{username}/approve")
            .route(web::post().to(join::approve_join)),
    );
}
