feat(ai+db): 知识库 3 表迁移 + Entity — rules/references/guides
Phase 3 Task 21: - ai_knowledge_rules: L1 规则表(条件表达式 + 动作文本) - ai_knowledge_references: L2 参考表(摘要 + pgvector 嵌入) - ai_knowledge_guides: L3 指南表(全文 + pgvector 嵌入)
This commit is contained in:
29
crates/erp-ai/src/entity/ai_knowledge_guides.rs
Normal file
29
crates/erp-ai/src/entity/ai_knowledge_guides.rs
Normal file
@@ -0,0 +1,29 @@
|
||||
use sea_orm::entity::prelude::*;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Serialize, Deserialize)]
|
||||
#[sea_orm(table_name = "ai_knowledge_guides")]
|
||||
pub struct Model {
|
||||
#[sea_orm(primary_key, auto_increment = false)]
|
||||
pub id: Uuid,
|
||||
pub tenant_id: Uuid,
|
||||
pub title: String,
|
||||
pub analysis_type: String,
|
||||
pub content: String,
|
||||
pub category: Option<String>,
|
||||
// pgvector 字段 — SeaORM 不原生支持 vector 类型,查询时用 raw SQL
|
||||
#[sea_orm(ignore)]
|
||||
pub embedding: Option<Vec<f32>>,
|
||||
pub is_enabled: bool,
|
||||
pub created_at: DateTimeUtc,
|
||||
pub updated_at: DateTimeUtc,
|
||||
pub created_by: Option<Uuid>,
|
||||
pub updated_by: Option<Uuid>,
|
||||
pub deleted_at: Option<DateTimeUtc>,
|
||||
pub version_lock: i32,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
||||
pub enum Relation {}
|
||||
|
||||
impl ActiveModelBehavior for ActiveModel {}
|
||||
30
crates/erp-ai/src/entity/ai_knowledge_references.rs
Normal file
30
crates/erp-ai/src/entity/ai_knowledge_references.rs
Normal file
@@ -0,0 +1,30 @@
|
||||
use sea_orm::entity::prelude::*;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Serialize, Deserialize)]
|
||||
#[sea_orm(table_name = "ai_knowledge_references")]
|
||||
pub struct Model {
|
||||
#[sea_orm(primary_key, auto_increment = false)]
|
||||
pub id: Uuid,
|
||||
pub tenant_id: Uuid,
|
||||
pub title: String,
|
||||
pub analysis_type: String,
|
||||
pub source_name: String,
|
||||
pub content_summary: String,
|
||||
// pgvector 字段 — SeaORM 不原生支持 vector 类型,查询时用 raw SQL
|
||||
#[sea_orm(ignore)]
|
||||
pub embedding: Option<Vec<f32>>,
|
||||
pub tags: Option<serde_json::Value>,
|
||||
pub is_enabled: bool,
|
||||
pub created_at: DateTimeUtc,
|
||||
pub updated_at: DateTimeUtc,
|
||||
pub created_by: Option<Uuid>,
|
||||
pub updated_by: Option<Uuid>,
|
||||
pub deleted_at: Option<DateTimeUtc>,
|
||||
pub version_lock: i32,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
||||
pub enum Relation {}
|
||||
|
||||
impl ActiveModelBehavior for ActiveModel {}
|
||||
27
crates/erp-ai/src/entity/ai_knowledge_rules.rs
Normal file
27
crates/erp-ai/src/entity/ai_knowledge_rules.rs
Normal file
@@ -0,0 +1,27 @@
|
||||
use sea_orm::entity::prelude::*;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Serialize, Deserialize)]
|
||||
#[sea_orm(table_name = "ai_knowledge_rules")]
|
||||
pub struct Model {
|
||||
#[sea_orm(primary_key, auto_increment = false)]
|
||||
pub id: Uuid,
|
||||
pub tenant_id: Uuid,
|
||||
pub rule_name: String,
|
||||
pub analysis_type: String,
|
||||
pub condition_expr: String,
|
||||
pub action_text: String,
|
||||
pub priority: i32,
|
||||
pub is_enabled: bool,
|
||||
pub created_at: DateTimeUtc,
|
||||
pub updated_at: DateTimeUtc,
|
||||
pub created_by: Option<Uuid>,
|
||||
pub updated_by: Option<Uuid>,
|
||||
pub deleted_at: Option<DateTimeUtc>,
|
||||
pub version_lock: i32,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
||||
pub enum Relation {}
|
||||
|
||||
impl ActiveModelBehavior for ActiveModel {}
|
||||
@@ -1,5 +1,8 @@
|
||||
pub mod ai_analysis;
|
||||
pub mod ai_analysis_queue;
|
||||
pub mod ai_knowledge_guides;
|
||||
pub mod ai_knowledge_references;
|
||||
pub mod ai_knowledge_rules;
|
||||
pub mod ai_prompt;
|
||||
pub mod ai_risk_threshold;
|
||||
pub mod ai_suggestion;
|
||||
|
||||
Reference in New Issue
Block a user