use anyhow::Result; use axum::{http::StatusCode, response::IntoResponse, Json}; use diesel::Identifiable; use serde::Serialize; use std::marker::PhantomData; use crate::base::{entity::BaseEntity, i_service::IBaseService}; pub struct BaseController where T: BaseEntity + Identifiable + Serialize + Send + Sync + 'static, S: IBaseService + Send + Sync + 'static, { service: S, _marker: PhantomData, } impl BaseController where T: BaseEntity + Identifiable + Serialize + Send + Sync + 'static, S: IBaseService + Send + Sync + 'static, { pub fn new(service: S) -> Self { Self { service, _marker: PhantomData, } } pub async fn get_all(&self) -> Result { let entities = self.service.get_all().await?; Ok((StatusCode::OK, Json(entities))) } }