use super::{ testimonials_dto::{ TestimonialsCreateRequestDto, TestimonialsDetailItemDto, TestimonialsListItemDto, TestimonialsUpdateRequestDto, }, testimonials_service::TestimonialsService, }; use axum::extract::{Path, Query}; use axum::response::IntoResponse; use axum::{Extension, Json}; use imphnen_iam::UsersDetailQueryDto; use imphnen_libs::{ AppState, MessageResponseDto, MetaRequestDto, ResponseListSuccessDto, ResponseSuccessDto, }; #[utoipa::path( get, path = "/v1/cms/landing/testimonials", params( ("page" = Option, Query, description = "Page number"), ("per_page" = Option, Query, description = "Items per page"), ("search" = Option, Query, description = "Search keyword"), ("sort_by" = Option, Query, description = "Sort by field"), ("order" = Option, Query, description = "Order ASC or DESC"), ("filter" = Option, Query, description = "Filter value"), ("filter_by" = Option, Query, description = "Field to filter by"), ), responses( (status = 200, description = "Get testimonial list", body = ResponseListSuccessDto>) ), tag = "Testimonials" )] pub async fn get_testimonial_list( Extension(state): Extension, Query(meta): Query, ) -> impl IntoResponse { TestimonialsService::get_testimonial_list(&state, meta).await } #[utoipa::path( get, path = "/v1/cms/landing/testimonials/detail/{id}", params( ("id" = String, Path, description = "Testimonial ID") ), responses( (status = 200, description = "Get testimonial by ID", body = ResponseSuccessDto) ), tag = "Testimonials" )] pub async fn get_testimonial_by_id( Extension(state): Extension, Path(id): Path, ) -> impl IntoResponse { TestimonialsService::get_testimonial_by_id(&state, id).await } #[utoipa::path( post, security( ("Bearer" = []) ), path = "/v1/cms/landing/testimonials/create", request_body = TestimonialsCreateRequestDto, responses( (status = 201, description = "Create new testimonial", body = MessageResponseDto) ), tag = "Testimonials" )] pub async fn post_create_testimonial( Extension(state): Extension, Extension(authenticated_user): Extension, Json(payload): Json, ) -> impl IntoResponse { println!("Authenticated User Now: {:?}", authenticated_user); TestimonialsService::create_testimonial(&state, payload, &authenticated_user).await } #[utoipa::path( patch, security( ("Bearer" = []) ), path = "/v1/cms/landing/testimonials/update/{id}", params( ("id" = String, Path, description = "Testimonial ID") ), request_body = TestimonialsUpdateRequestDto, responses( (status = 200, description = "Update testimonial", body = MessageResponseDto) ), tag = "Testimonials" )] pub async fn patch_update_testimonial( Path(id): Path, Extension(state): Extension, Extension(authenticated_user): Extension, Json(payload): Json, ) -> impl IntoResponse { TestimonialsService::update_testimonial(&state, id, payload, &authenticated_user) .await } #[utoipa::path( delete, security( ("Bearer" = []) ), path = "/v1/cms/landing/testimonials/delete/{id}", params( ("id" = String, Path, description = "Testimonial ID") ), responses( (status = 200, description = "Soft delete testimonial", body = MessageResponseDto) ), tag = "Testimonials" )] pub async fn delete_testimonial( Extension(state): Extension, Extension(authenticated_user): Extension, Path(id): Path, ) -> impl IntoResponse { TestimonialsService::delete_testimonial(&state, id, &authenticated_user).await }