Fundamental_Analysis/services/common-contracts/src/dtos.rs
Lv, Qi 427776b863 feat(analysis): Implement Configurable Analysis Template Engine
This commit introduces a comprehensive, template-based analysis orchestration system, refactoring the entire analysis generation workflow from the ground up.

Key Changes:

1.  **Backend Architecture (`report-generator-service`):**
    *   Replaced the naive analysis workflow with a robust orchestrator based on a Directed Acyclic Graph (DAG) of module dependencies.
    *   Implemented a full topological sort (`petgraph`) to determine the correct execution order and detect circular dependencies.

2.  **Data Models (`common-contracts`, `data-persistence-service`):**
    *   Introduced the concept of `AnalysisTemplateSets` to allow for multiple, independent, and configurable analysis workflows.
    *   Created a new `analysis_results` table to persist the output of each module for every analysis run, ensuring traceability.
    *   Implemented a file-free data seeding mechanism to populate default analysis templates on service startup.

3.  **API Layer (`api-gateway`):**
    *   Added a new asynchronous endpoint (`POST /analysis-requests/{symbol}`) to trigger analysis workflows via NATS messages.
    *   Updated all configuration endpoints to support the new `AnalysisTemplateSets` model.

4.  **Frontend UI (`/config`, `/query`):**
    *   Completely refactored the "Analysis Config" page into a two-level management UI for "Template Sets" and the "Modules" within them, supporting full CRUD operations.
    *   Updated the "Query" page to allow users to select which analysis template to use when generating a report.

This new architecture provides a powerful, flexible, and robust foundation for all future development of our intelligent analysis capabilities.
2025-11-18 07:47:08 +08:00

94 lines
2.1 KiB
Rust

use chrono::NaiveDate;
use service_kit::api_dto;
use serde_json::Value as JsonValue;
use uuid::Uuid;
// Companies API DTOs
#[api_dto]
pub struct CompanyProfileDto {
pub symbol: String,
pub name: String,
pub industry: Option<String>,
pub list_date: Option<NaiveDate>,
pub additional_info: Option<JsonValue>,
}
// Market Data API DTOs
#[api_dto]
pub struct TimeSeriesFinancialDto {
pub symbol: String,
pub metric_name: String,
pub period_date: NaiveDate,
pub value: f64,
pub source: Option<String>,
}
#[api_dto]
pub struct DailyMarketDataDto {
pub symbol: String,
pub trade_date: NaiveDate,
pub open_price: Option<f64>,
pub high_price: Option<f64>,
pub low_price: Option<f64>,
pub close_price: Option<f64>,
pub volume: Option<i64>,
pub pe: Option<f64>,
pub pb: Option<f64>,
pub total_mv: Option<f64>,
}
// Batch DTOs
#[api_dto]
pub struct TimeSeriesFinancialBatchDto {
pub records: Vec<TimeSeriesFinancialDto>,
}
#[api_dto]
pub struct DailyMarketDataBatchDto {
pub records: Vec<DailyMarketDataDto>,
}
// Analysis Results API DTOs (NEW)
#[api_dto]
pub struct NewAnalysisResult {
pub request_id: Uuid,
pub symbol: String,
pub template_id: String,
pub module_id: String,
pub content: String,
pub meta_data: JsonValue,
}
/// Represents a persisted analysis result read from the database.
#[api_dto]
pub struct AnalysisResultDto {
pub id: i64,
pub request_id: Uuid,
pub symbol: String,
pub template_id: String,
pub module_id: String,
pub content: String,
pub meta_data: JsonValue,
pub created_at: chrono::DateTime<chrono::Utc>,
}
// Realtime Quotes DTOs
#[api_dto]
pub struct RealtimeQuoteDto {
pub symbol: String,
pub market: String,
pub ts: chrono::DateTime<chrono::Utc>,
pub price: f64,
pub open_price: Option<f64>,
pub high_price: Option<f64>,
pub low_price: Option<f64>,
pub prev_close: Option<f64>,
pub change: Option<f64>,
pub change_percent: Option<f64>,
pub volume: Option<i64>,
pub source: Option<String>,
}