Route structure: /v1/iam/auth/* (was /v1/auth/*) /v1/iam/users/* (was /v1/users/*) /v1/iam/roles/* (was /v1/roles/*) /v1/iam/permissions/* (was /v1/permissions/*) /v1/landing/cms/events/* (was /v1/cms/landing/events/*) /v1/landing/cms/testimonials/* (was /v1/cms/landing/testimonials/*) /v1/dimentorin/mentors/* (was /v1/mentors/*) /v1/dimentorin/sessions/* (was /v1/sessions/*) /v1/gacha/* (unchanged) /v1/hackathon/* (unchanged) /v1/qr/* (unchanged) Swagger: add gacha_credits endpoints which were missing from OpenAPI spec. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
36 lines
1.1 KiB
Rust
36 lines
1.1 KiB
Rust
use super::handlers::{
|
|
delete_event, get_event_by_id, get_event_list, patch_update_event,
|
|
post_create_event,
|
|
};
|
|
use crate::events::application::EventServiceImpl;
|
|
use crate::events::domain::EventService;
|
|
use crate::events::infrastructure::persistence::PostgresEventRepository;
|
|
use axum::{
|
|
Extension, Router,
|
|
routing::{delete, get, patch, post},
|
|
};
|
|
use sea_orm::DatabaseConnection;
|
|
use std::sync::Arc;
|
|
|
|
fn build_service(db: DatabaseConnection) -> Arc<dyn EventService> {
|
|
let repo = Arc::new(PostgresEventRepository::new(db));
|
|
Arc::new(EventServiceImpl::new(repo))
|
|
}
|
|
|
|
pub fn events_public_routes(db: DatabaseConnection) -> Router {
|
|
let service = build_service(db);
|
|
Router::new()
|
|
.route("/events", get(get_event_list))
|
|
.route("/events/detail/{id}", get(get_event_by_id))
|
|
.layer(Extension(service))
|
|
}
|
|
|
|
pub fn events_protected_routes(db: DatabaseConnection) -> Router {
|
|
let service = build_service(db);
|
|
Router::new()
|
|
.route("/events/create", post(post_create_event))
|
|
.route("/events/update/{id}", patch(patch_update_event))
|
|
.route("/events/delete/{id}", delete(delete_event))
|
|
.layer(Extension(service))
|
|
}
|