Files
erp/crates/erp-plugin/src/data_dto.rs

108 lines
2.9 KiB
Rust
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};
/// 插件数据记录响应
#[derive(Debug, Serialize, Deserialize, utoipa::ToSchema)]
pub struct PluginDataResp {
pub id: String,
pub data: serde_json::Value,
pub created_at: Option<DateTime<Utc>>,
pub updated_at: Option<DateTime<Utc>>,
pub version: Option<i32>,
}
/// 创建插件数据请求
#[derive(Debug, Serialize, Deserialize, utoipa::ToSchema)]
pub struct CreatePluginDataReq {
pub data: serde_json::Value,
}
/// 更新插件数据请求(全量替换)
#[derive(Debug, Serialize, Deserialize, utoipa::ToSchema)]
pub struct UpdatePluginDataReq {
pub data: serde_json::Value,
pub version: i32,
}
/// 部分更新请求PATCH — 只合并提供的字段)
#[derive(Debug, Serialize, Deserialize, utoipa::ToSchema)]
pub struct PatchPluginDataReq {
pub data: serde_json::Value,
pub version: i32,
}
/// 插件数据列表查询参数
#[derive(Debug, Serialize, Deserialize, utoipa::IntoParams)]
pub struct PluginDataListParams {
pub page: Option<u64>,
pub page_size: Option<u64>,
/// Base64 编码的游标(用于 Keyset 分页)
pub cursor: Option<String>,
pub search: Option<String>,
/// JSON 格式过滤: {"field":"value"}
pub filter: Option<String>,
pub sort_by: Option<String>,
/// "asc" or "desc"
pub sort_order: Option<String>,
}
/// 聚合查询响应项
#[derive(Debug, Serialize, Deserialize, utoipa::ToSchema)]
pub struct AggregateItem {
/// 分组键(字段值)
pub key: String,
/// 计数
pub count: i64,
}
/// 聚合查询参数
#[derive(Debug, Serialize, Deserialize, utoipa::IntoParams)]
pub struct AggregateQueryParams {
/// 分组字段名
pub group_by: String,
/// JSON 格式过滤: {"field":"value"}
pub filter: Option<String>,
}
/// 统计查询参数
#[derive(Debug, Serialize, Deserialize, utoipa::IntoParams)]
pub struct CountQueryParams {
/// 搜索关键词
pub search: Option<String>,
/// JSON 格式过滤: {"field":"value"}
pub filter: Option<String>,
}
/// 批量操作请求
#[derive(Debug, Serialize, Deserialize, utoipa::ToSchema)]
pub struct BatchActionReq {
/// 操作类型: "batch_delete" 或 "batch_update"
pub action: String,
/// 记录 ID 列表(上限 100
pub ids: Vec<String>,
/// batch_update 时的更新数据
pub data: Option<serde_json::Value>,
}
/// 时间序列查询参数
#[derive(Debug, Serialize, Deserialize, utoipa::IntoParams)]
pub struct TimeseriesParams {
/// 时间字段名
pub time_field: String,
/// 时间粒度: "day" / "week" / "month"
pub time_grain: String,
/// 开始日期 (ISO)
pub start: Option<String>,
/// 结束日期 (ISO)
pub end: Option<String>,
}
/// 时间序列数据项
#[derive(Debug, Serialize, Deserialize, utoipa::ToSchema)]
pub struct TimeseriesItem {
/// 时间周期
pub period: String,
/// 计数
pub count: i64,
}