2026-04-02 22:29:08 +07:00
|
|
|
use super::handlers::{get_gacha_claim_by_id, post_create_gacha_claim};
|
2026-04-02 13:39:52 +07:00
|
|
|
use crate::gacha_claims::application::GachaClaimServiceImpl;
|
|
|
|
|
use crate::gacha_claims::domain::GachaClaimService;
|
|
|
|
|
use crate::gacha_claims::infrastructure::persistence::PostgresGachaClaimRepository;
|
2026-04-02 22:29:08 +07:00
|
|
|
use axum::{
|
|
|
|
|
Extension, Router,
|
|
|
|
|
routing::{get, post},
|
|
|
|
|
};
|
|
|
|
|
use sea_orm::DatabaseConnection;
|
|
|
|
|
use std::sync::Arc;
|
2026-04-02 13:39:52 +07:00
|
|
|
|
2026-04-02 22:29:08 +07:00
|
|
|
fn build_service(
|
|
|
|
|
db: DatabaseConnection,
|
|
|
|
|
state: std::sync::Arc<imphnen_libs::AppState>,
|
|
|
|
|
) -> Arc<dyn GachaClaimService> {
|
|
|
|
|
let repo = Arc::new(PostgresGachaClaimRepository::new(db, state));
|
|
|
|
|
Arc::new(GachaClaimServiceImpl::new(repo))
|
2026-04-02 13:39:52 +07:00
|
|
|
}
|
|
|
|
|
|
2026-04-02 22:29:08 +07:00
|
|
|
pub fn gacha_claim_router(
|
|
|
|
|
db: DatabaseConnection,
|
|
|
|
|
state: std::sync::Arc<imphnen_libs::AppState>,
|
|
|
|
|
) -> Router {
|
|
|
|
|
let service = build_service(db, state);
|
|
|
|
|
Router::new()
|
|
|
|
|
.route("/detail/{id}", get(get_gacha_claim_by_id))
|
|
|
|
|
.route("/create", post(post_create_gacha_claim))
|
|
|
|
|
.layer(Extension(service))
|
2026-04-02 13:39:52 +07:00
|
|
|
}
|