2026-04-02 22:29:08 +07:00
|
|
|
use super::handlers::{
|
|
|
|
|
delete_testimonial, get_testimonial_by_id, get_testimonial_list,
|
|
|
|
|
patch_update_testimonial, post_create_testimonial,
|
|
|
|
|
};
|
2026-04-02 13:39:52 +07:00
|
|
|
use crate::testimonials::application::TestimonialServiceImpl;
|
|
|
|
|
use crate::testimonials::domain::TestimonialService;
|
|
|
|
|
use crate::testimonials::infrastructure::persistence::PostgresTestimonialRepository;
|
2026-04-02 22:29:08 +07:00
|
|
|
use axum::{
|
|
|
|
|
Extension, Router,
|
|
|
|
|
routing::{delete, get, patch, post},
|
2026-04-02 13:39:52 +07:00
|
|
|
};
|
2026-04-02 22:29:08 +07:00
|
|
|
use sea_orm::DatabaseConnection;
|
|
|
|
|
use std::sync::Arc;
|
2026-04-02 13:39:52 +07:00
|
|
|
|
|
|
|
|
fn build_service(db: DatabaseConnection) -> Arc<dyn TestimonialService> {
|
2026-04-02 22:29:08 +07:00
|
|
|
let repo = Arc::new(PostgresTestimonialRepository::new(db));
|
|
|
|
|
Arc::new(TestimonialServiceImpl::new(repo))
|
2026-04-02 13:39:52 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn testimonials_public_routes(db: DatabaseConnection) -> Router {
|
2026-04-02 22:29:08 +07:00
|
|
|
let service = build_service(db);
|
|
|
|
|
Router::new()
|
|
|
|
|
.route("/cms/landing/testimonials", get(get_testimonial_list))
|
|
|
|
|
.route(
|
|
|
|
|
"/cms/landing/testimonials/detail/{id}",
|
|
|
|
|
get(get_testimonial_by_id),
|
|
|
|
|
)
|
|
|
|
|
.layer(Extension(service))
|
2026-04-02 13:39:52 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn testimonials_protected_routes(db: DatabaseConnection) -> Router {
|
2026-04-02 22:29:08 +07:00
|
|
|
let service = build_service(db);
|
|
|
|
|
Router::new()
|
|
|
|
|
.route(
|
|
|
|
|
"/cms/landing/testimonials/create",
|
|
|
|
|
post(post_create_testimonial),
|
|
|
|
|
)
|
|
|
|
|
.route(
|
|
|
|
|
"/cms/landing/testimonials/update/{id}",
|
|
|
|
|
patch(patch_update_testimonial),
|
|
|
|
|
)
|
|
|
|
|
.route(
|
|
|
|
|
"/cms/landing/testimonials/delete/{id}",
|
|
|
|
|
delete(delete_testimonial),
|
|
|
|
|
)
|
|
|
|
|
.layer(Extension(service))
|
2026-04-02 13:39:52 +07:00
|
|
|
}
|