sz-rust-cli 1.4.0

SZ-Rust 命令行工具:项目脚手架、数据库迁移、调度器管理
Documentation
// Generated by sz-rust-cli make:plugin --template {{ template_type }} --name {{ plugin_name }}
// Generation time: {{ generated_at }}
// DO NOT EDIT MANUALLY

//! Report model for `{{ table_name }}` with aggregation dimensions and metrics

use serde::{Deserialize, Serialize};

/// Aggregation dimension
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Dimension {
    pub field: String,
    pub value: serde_json::Value,
}

/// Metric aggregation result
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct MetricResult {
    {%- for metric in metrics %}
    pub {{ metric.name }}: {{ metric.rust_type }},
    {%- endfor %}
}

/// Report row: dimensions + metrics
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct {{ class_name }}ReportRow {
    pub dimensions: Vec<Dimension>,
    pub metrics: MetricResult,
}

/// Report query parameters
#[derive(Debug, Clone, Deserialize)]
pub struct {{ class_name }}ReportQuery {
    /// Group by dimensions
    pub group_by: Vec<String>,
    /// Date range start (ISO 8601)
    pub date_from: Option<String>,
    /// Date range end (ISO 8601)
    pub date_to: Option<String>,
    /// Sort field
    pub sort_by: Option<String>,
    /// Sort order: "asc" or "desc"
    pub sort_order: Option<String>,
    /// Page number (1-based)
    pub page: Option<u32>,
    /// Page size
    pub page_size: Option<u32>,
}

impl Default for {{ class_name }}ReportQuery {
    fn default() -> Self {
        Self {
            group_by: vec![{%- for dim in dimensions %}"{{ dim.field }}"{%- if not loop.last %}, {% endif %}{%- endfor %}],
            date_from: None,
            date_to: None,
            sort_by: None,
            sort_order: Some("desc".to_string()),
            page: Some(1),
            page_size: Some(20),
        }
    }
}