feat(plugin): P1 跨插件数据引用系统 — 后端 Phase 1-3
实现跨插件实体引用的基础后端能力:
Phase 1 — Manifest 扩展 + Entity Registry 数据层:
- PluginField 新增 ref_plugin/ref_fallback_label 支持跨插件引用声明
- PluginRelation 新增 name/relation_type/display_field(CRM 已在用的字段)
- PluginEntity 新增 is_public 标记可被其他插件引用的实体
- 数据库迁移:plugin_entities 新增 manifest_id + is_public 列 + 索引
- SeaORM Entity 和 install 流程同步更新
Phase 2 — 后端跨插件引用解析 + 校验:
- data_service: 新增 resolve_cross_plugin_entity/is_plugin_active 函数
- validate_ref_entities: 支持 ref_plugin 字段,目标插件未安装时跳过校验(软警告)
- host.rs: HostState 新增 cross_plugin_entities 映射,db_query 支持点分记号
- engine.rs: execute_wasm 自动构建跨插件实体映射
Phase 3 — API 端点:
- POST /plugins/{id}/{entity}/resolve-labels 批量标签解析
- GET /plugin-registry/entities 公开实体注册表查询
This commit is contained in:
@@ -55,6 +55,18 @@ pub struct AggregateItem {
|
||||
pub count: i64,
|
||||
}
|
||||
|
||||
/// 多聚合查询响应项
|
||||
#[derive(Debug, Serialize, Deserialize, utoipa::ToSchema)]
|
||||
pub struct AggregateMultiRow {
|
||||
/// 分组键
|
||||
pub key: String,
|
||||
/// 计数
|
||||
pub count: i64,
|
||||
/// 聚合指标: {"sum_amount": 5000.0, "avg_price": 25.5}
|
||||
#[serde(default)]
|
||||
pub metrics: std::collections::HashMap<String, f64>,
|
||||
}
|
||||
|
||||
/// 聚合查询参数
|
||||
#[derive(Debug, Serialize, Deserialize, utoipa::IntoParams)]
|
||||
pub struct AggregateQueryParams {
|
||||
@@ -64,6 +76,26 @@ pub struct AggregateQueryParams {
|
||||
pub filter: Option<String>,
|
||||
}
|
||||
|
||||
/// 多聚合查询请求体
|
||||
#[derive(Debug, Serialize, Deserialize, utoipa::ToSchema)]
|
||||
pub struct AggregateMultiReq {
|
||||
/// 分组字段名
|
||||
pub group_by: String,
|
||||
/// 聚合定义列表: [{"func": "sum", "field": "amount"}]
|
||||
pub aggregations: Vec<AggregateDefDto>,
|
||||
/// JSON 格式过滤
|
||||
pub filter: Option<serde_json::Value>,
|
||||
}
|
||||
|
||||
/// 单个聚合定义
|
||||
#[derive(Debug, Serialize, Deserialize, utoipa::ToSchema)]
|
||||
pub struct AggregateDefDto {
|
||||
/// 聚合函数: count, sum, avg, min, max
|
||||
pub func: String,
|
||||
/// 字段名
|
||||
pub field: String,
|
||||
}
|
||||
|
||||
/// 统计查询参数
|
||||
#[derive(Debug, Serialize, Deserialize, utoipa::IntoParams)]
|
||||
pub struct CountQueryParams {
|
||||
@@ -105,3 +137,29 @@ pub struct TimeseriesItem {
|
||||
/// 计数
|
||||
pub count: i64,
|
||||
}
|
||||
|
||||
// ─── 跨插件引用 DTO ──────────────────────────────────────────────────
|
||||
|
||||
/// 批量标签解析请求
|
||||
#[derive(Debug, Serialize, Deserialize, utoipa::ToSchema)]
|
||||
pub struct ResolveLabelsReq {
|
||||
/// 字段名 → UUID 列表
|
||||
pub fields: std::collections::HashMap<String, Vec<String>>,
|
||||
}
|
||||
|
||||
/// 批量标签解析响应
|
||||
#[derive(Debug, Serialize, Deserialize, utoipa::ToSchema)]
|
||||
pub struct ResolveLabelsResp {
|
||||
/// 字段名 → { uuid: label } 映射
|
||||
pub labels: serde_json::Value,
|
||||
/// 字段名 → 目标插件元信息
|
||||
pub meta: serde_json::Value,
|
||||
}
|
||||
|
||||
/// 公开实体信息(实体注册表查询响应)
|
||||
#[derive(Debug, Serialize, Deserialize, utoipa::ToSchema)]
|
||||
pub struct PublicEntityResp {
|
||||
pub manifest_id: String,
|
||||
pub entity_name: String,
|
||||
pub display_name: String,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user