Phase 0: 知识库
- docs/knowledge-base/loco-rs-patterns.md — loco-rs 10 个可借鉴模式研究
Phase 1: 数据层重构
- crates/zclaw-saas/src/models/ — 15 个 FromRow 类型化模型
- Login 3 次查询合并为 1 次 AccountLoginRow 查询
- 所有 service 文件从元组解构迁移到 FromRow 结构体
Phase 2: Worker + Scheduler 系统
- crates/zclaw-saas/src/workers/ — Worker trait + 5 个具体实现
- crates/zclaw-saas/src/scheduler.rs — TOML 声明式调度器
- crates/zclaw-saas/src/tasks/ — CLI 任务系统
Phase 3: 性能修复
- Relay N+1 查询 → 精准 SQL (relay/handlers.rs)
- Config RwLock → AtomicU32 无锁 rate limit (state.rs, middleware.rs)
- SSE std::sync::Mutex → tokio::sync::Mutex (relay/service.rs)
- /auth/refresh 阻塞清理 → Scheduler 定期执行
Phase 4: 多环境配置
- config/saas-{development,production,test}.toml
- ZCLAW_ENV 环境选择 + ZCLAW_SAAS_CONFIG 精确覆盖
- scheduler 配置集成到 TOML
32 lines
767 B
Rust
32 lines
767 B
Rust
//! prompt_templates + prompt_versions 表相关模型
|
|
|
|
use sqlx::FromRow;
|
|
|
|
/// prompt_templates 表行
|
|
#[derive(Debug, FromRow)]
|
|
pub struct PromptTemplateRow {
|
|
pub id: String,
|
|
pub name: String,
|
|
pub category: String,
|
|
pub description: Option<String>,
|
|
pub source: String,
|
|
pub current_version: i32,
|
|
pub status: String,
|
|
pub created_at: String,
|
|
pub updated_at: String,
|
|
}
|
|
|
|
/// prompt_versions 表行
|
|
#[derive(Debug, FromRow)]
|
|
pub struct PromptVersionRow {
|
|
pub id: String,
|
|
pub template_id: String,
|
|
pub version: i32,
|
|
pub system_prompt: String,
|
|
pub user_prompt_template: Option<String>,
|
|
pub variables: String,
|
|
pub changelog: Option<String>,
|
|
pub min_app_version: Option<String>,
|
|
pub created_at: String,
|
|
}
|