// Generated by sz-rust-cli make:plugin --template {{ template_type }} --name {{ plugin_name }}
// Generation time: {{ generated_at }}
// DO NOT EDIT MANUALLY — regenerate with `sz-rust-cli make:plugin --force ...`
use axum::extract::Path;
use axum::http::StatusCode;
use axum::Json;
use super::model::{% block model_import %}{{ class_name }}{% endblock %};
use super::service::{% block service_import %}{{ class_name }}Service{% endblock %};
/// Controller for `{% block route_prefix %}{{ table_name }}{% endblock %}`
pub struct {% block controller_name %}{{ class_name }}Controller{% endblock %};
impl {% block controller_impl %}{{ class_name }}Controller{% endblock %} {
/// GET /{% block route_index %}{{ table_name }}{% endblock %} — List all records
pub async fn index() -> Result<Json<Vec<{% block model_index %}{{ class_name }}{% endblock %}>>, (StatusCode, String)> {
todo!()
}
/// GET /{% block route_create %}{{ table_name }}{% endblock %}/create — Show create form
pub async fn create() -> Result<String, (StatusCode, String)> {
todo!()
}
/// POST /{% block route_save %}{{ table_name }}{% endblock %} — Save new record
pub async fn save(
Json(payload): Json<{% block model_save %}{{ class_name }}{% endblock %}>,
) -> Result<Json<{% block model_save_ret %}{{ class_name }}{% endblock %}>, (StatusCode, String)> {
todo!()
}
/// GET /{% block route_read %}{{ table_name }}{% endblock %}/{id} — Show single record
pub async fn read(
Path(id): Path<{{ primary_key_type }}>,
) -> Result<Json<{% block model_read %}{{ class_name }}{% endblock %}>, (StatusCode, String)> {
todo!()
}
/// GET /{% block route_edit %}{{ table_name }}{% endblock %}/{id}/edit — Show edit form
pub async fn edit(
Path(id): Path<{{ primary_key_type }}>,
) -> Result<String, (StatusCode, String)> {
todo!()
}
/// PUT /{% block route_update %}{{ table_name }}{% endblock %}/{id} — Update record
pub async fn update(
Path(id): Path<{{ primary_key_type }}>,
Json(payload): Json<{% block model_update %}{{ class_name }}{% endblock %}>,
) -> Result<Json<{% block model_update_ret %}{{ class_name }}{% endblock %}>, (StatusCode, String)> {
todo!()
}
/// DELETE /{% block route_delete %}{{ table_name }}{% endblock %}/{id} — Delete record
pub async fn delete(
Path(id): Path<{{ primary_key_type }}>,
) -> Result<StatusCode, (StatusCode, String)> {
todo!()
}
}