feat(rapor): aylık değerlendirme raporu backend (şablon, yorumlar, öneriler)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -9,6 +9,7 @@ mod catalog;
|
||||
mod entry;
|
||||
mod health;
|
||||
mod household;
|
||||
mod monthly_report;
|
||||
mod note;
|
||||
mod period;
|
||||
mod plan;
|
||||
@@ -90,6 +91,7 @@ pub fn router(state: AppState) -> Router {
|
||||
.route("/periods/{id}/notes", get(note::list).post(note::create))
|
||||
.route("/periods/{id}/summary", get(budget::summary))
|
||||
.route("/periods/{id}/review", get(review::get))
|
||||
.route("/periods/{id}/report.md", get(monthly_report::get))
|
||||
.route("/periods/{id}/daily", get(stats::daily))
|
||||
.route("/stats/periods", get(stats::periods))
|
||||
.route("/reports/breakdown", get(reports::breakdown))
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
//! Aylık değerlendirme raporu (`services::monthly_report`, şablon `templates/monthly_report.md`).
|
||||
//!
|
||||
//! | Yöntem | Yol | İş |
|
||||
//! |---|---|---|
|
||||
//! | GET | `/api/periods/{id}/report.md` | dönemin raporu (Markdown); açık dönem → ara rapor |
|
||||
|
||||
use axum::{
|
||||
extract::{Path, State},
|
||||
http::header,
|
||||
response::IntoResponse,
|
||||
};
|
||||
use mongodb::bson::Uuid;
|
||||
|
||||
use crate::{
|
||||
auth::AuthUser,
|
||||
error::{AppError, AppResult},
|
||||
services::{backup::slug, monthly_report, period},
|
||||
state::AppState,
|
||||
};
|
||||
|
||||
pub async fn get(
|
||||
State(s): State<AppState>,
|
||||
auth: AuthUser,
|
||||
Path(id): Path<String>,
|
||||
) -> AppResult<impl IntoResponse> {
|
||||
let id = Uuid::parse_str(&id).map_err(|_| AppError::NotFound)?;
|
||||
let p = period::get(&s.db, auth.household_id, id).await?;
|
||||
let body = monthly_report::markdown(&s.db, auth.household_id, id).await?;
|
||||
let file = format!("kakeibo-rapor-{}.md", slug(&p.name));
|
||||
Ok((
|
||||
[
|
||||
(
|
||||
header::CONTENT_TYPE,
|
||||
"text/markdown; charset=utf-8".to_string(),
|
||||
),
|
||||
(
|
||||
header::CONTENT_DISPOSITION,
|
||||
format!("inline; filename=\"{file}\""),
|
||||
),
|
||||
(header::CACHE_CONTROL, "no-store".to_string()),
|
||||
],
|
||||
body,
|
||||
))
|
||||
}
|
||||
@@ -13,6 +13,7 @@ pub mod entry;
|
||||
pub mod holding;
|
||||
pub mod invite;
|
||||
pub mod money;
|
||||
pub mod monthly_report;
|
||||
pub mod note;
|
||||
pub mod period;
|
||||
pub mod plan;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user