feat: 同步知识库与工作台相关改动

This commit is contained in:
Jackzhou
2026-08-24 10:40:15 +08:00
parent 8d0588827d
commit 4f33b036d1
50 changed files with 8034 additions and 273 deletions
@@ -5,10 +5,11 @@ import "time"
// KnowledgeChunk 知识块表(AI 检索最小单元)
type KnowledgeChunk struct {
ID uint `gorm:"primaryKey" json:"id"`
MediaFileID *uint `gorm:"index" json:"media_file_id"` // 与 knowledge_source_id 二选一
KnowledgeSourceID *uint `gorm:"index" json:"knowledge_source_id"` // 与 media_file_id 二选一
MediaFileID *uint `gorm:"index" json:"media_file_id"` // 与 knowledge_source_id 二选一
KnowledgeSourceID *uint `gorm:"index" json:"knowledge_source_id"` // 与 media_file_id 二选一
SourceType string `gorm:"size:32;not null" json:"source_type"` // pdf/doc/md
SourceID string `gorm:"size:64" json:"source_id"`
KnowledgeSpaceKey string `gorm:"size:64;index" json:"knowledge_space_key"`
ChunkIndex int `gorm:"not null" json:"chunk_index"`
Content string `gorm:"type:text;not null" json:"content"`
CreatedAt time.Time `json:"created_at"`
@@ -0,0 +1,20 @@
package model
import "time"
// KnowledgeFAQ FAQ 标准问答表
type KnowledgeFAQ struct {
ID uint `gorm:"primaryKey" json:"id"`
KnowledgeSpaceKey string `gorm:"size:64;index" json:"knowledge_space_key"`
Question string `gorm:"size:512;not null" json:"question"`
Answer string `gorm:"type:text;not null" json:"answer"`
SimilarQuestions string `gorm:"type:text" json:"similar_questions"`
Keywords string `gorm:"size:512" json:"keywords"`
Status string `gorm:"size:16;not null;default:active;index" json:"status"`
SortOrder int `gorm:"not null;default:0" json:"sort_order"`
HitCount int `gorm:"not null;default:0" json:"hit_count"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
func (KnowledgeFAQ) TableName() string { return "knowledge_faq" }
@@ -4,19 +4,20 @@ import "time"
// KnowledgeSource 结构化知识源表
type KnowledgeSource struct {
ID uint `gorm:"primaryKey" json:"id"`
Title string `gorm:"size:256;not null" json:"title"`
FilePath string `gorm:"size:512;uniqueIndex;not null" json:"file_path"`
Category string `gorm:"size:64;not null;index" json:"category"` // general/capital_consulting/qualification_counseling/ai_consulting/ai_tools_platform
Domain string `gorm:"size:16;not null;default:product" json:"domain"` // company / product / sales
SourceVersion string `gorm:"size:32;not null" json:"source_version"`
AuditStatus string `gorm:"size:16;not null;default:pending;index" json:"audit_status"` // pending / approved / rejected
AuditBy *uint `json:"audit_by"`
AuditAt *time.Time `json:"audit_at"`
RejectReason string `gorm:"size:512" json:"reject_reason"`
Ingested bool `gorm:"not null;default:false" json:"ingested"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
ID uint `gorm:"primaryKey" json:"id"`
Title string `gorm:"size:256;not null" json:"title"`
FilePath string `gorm:"size:512;uniqueIndex;not null" json:"file_path"`
Category string `gorm:"size:64;not null;index" json:"category"` // general/capital_consulting/qualification_counseling/ai_consulting/ai_tools_platform
Domain string `gorm:"size:16;not null;default:product" json:"domain"` // company / product / sales
SourceVersion string `gorm:"size:32;not null" json:"source_version"`
AuditStatus string `gorm:"size:16;not null;default:pending;index" json:"audit_status"` // pending / approved / rejected
KnowledgeSpaceKey string `gorm:"size:64;index" json:"knowledge_space_key"`
AuditBy *uint `json:"audit_by"`
AuditAt *time.Time `json:"audit_at"`
RejectReason string `gorm:"size:512" json:"reject_reason"`
Ingested bool `gorm:"not null;default:false" json:"ingested"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
func (KnowledgeSource) TableName() string { return "knowledge_source" }
@@ -0,0 +1,19 @@
package model
import "time"
// KnowledgeSpace 知识空间定义,供知识库应用与知识库管理共享。
type KnowledgeSpace struct {
ID uint `gorm:"primaryKey" json:"id"`
Key string `gorm:"size:64;uniqueIndex;not null" json:"key"`
Name string `gorm:"size:128;not null" json:"name"`
Description string `gorm:"size:512" json:"description"`
Scope string `gorm:"size:32;not null;default:general" json:"scope"`
Status string `gorm:"size:16;not null;default:active;index" json:"status"`
SortOrder int `gorm:"not null;default:0" json:"sort_order"`
IsDefault bool `gorm:"not null;default:false" json:"is_default"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
func (KnowledgeSpace) TableName() string { return "knowledge_space" }
@@ -4,23 +4,24 @@ import "time"
// MediaFile 素材文件表
type MediaFile struct {
ID uint `gorm:"primaryKey" json:"id"`
Filename string `gorm:"size:256;not null" json:"filename"`
StoredName string `gorm:"size:64;not null" json:"stored_name"`
StoredPath string `gorm:"size:512;not null" json:"stored_path"`
FileExt string `gorm:"size:16;not null" json:"file_ext"`
FileSize int64 `gorm:"not null" json:"file_size"`
Status string `gorm:"size:16;not null;default:pending;index" json:"status"` // pending / approved / rejected
Source string `gorm:"size:16;not null" json:"source"` // employee / admin
SubmitterID uint `gorm:"not null;index" json:"submitter_id"`
BindType string `gorm:"size:16;not null;default:none" json:"bind_type"` // company / product / course / none
BindID *uint `gorm:"index" json:"bind_id"`
Remark string `gorm:"size:512" json:"remark"` // 提交备注(员工素材建议)
RejectReason string `gorm:"size:512" json:"reject_reason"`
AuditBy *uint `json:"audit_by"`
AuditAt *time.Time `json:"audit_at"`
Extracted bool `gorm:"not null;default:false;index" json:"extracted"`
CreatedAt time.Time `json:"created_at"`
ID uint `gorm:"primaryKey" json:"id"`
Filename string `gorm:"size:256;not null" json:"filename"`
StoredName string `gorm:"size:64;not null" json:"stored_name"`
StoredPath string `gorm:"size:512;not null" json:"stored_path"`
FileExt string `gorm:"size:16;not null" json:"file_ext"`
FileSize int64 `gorm:"not null" json:"file_size"`
Status string `gorm:"size:16;not null;default:pending;index" json:"status"` // pending / approved / rejected
Source string `gorm:"size:16;not null" json:"source"` // employee / admin
SubmitterID uint `gorm:"not null;index" json:"submitter_id"`
BindType string `gorm:"size:16;not null;default:none" json:"bind_type"` // company / product / course / none
BindID *uint `gorm:"index" json:"bind_id"`
Remark string `gorm:"size:512" json:"remark"` // 提交备注(员工素材建议)
RejectReason string `gorm:"size:512" json:"reject_reason"`
AuditBy *uint `json:"audit_by"`
AuditAt *time.Time `json:"audit_at"`
KnowledgeSpaceKey string `gorm:"size:64;index" json:"knowledge_space_key"`
Extracted bool `gorm:"not null;default:false;index" json:"extracted"`
CreatedAt time.Time `json:"created_at"`
}
func (MediaFile) TableName() string { return "media_file" }
@@ -0,0 +1,21 @@
package model
import "time"
// WorkerArtifact 专员交付物
type WorkerArtifact struct {
ID uint `gorm:"primaryKey" json:"id"`
TaskID uint `gorm:"not null;index" json:"task_id"`
SpecialistKey string `gorm:"size:64;not null;index" json:"specialist_key"`
Title string `gorm:"size:128;not null" json:"title"`
ArtifactType string `gorm:"size:32;not null;default:text" json:"artifact_type"`
Status string `gorm:"size:32;not null;default:draft;index" json:"status"`
ContentText string `gorm:"type:text" json:"content_text"`
ContentJSON string `gorm:"type:text" json:"content_json"`
SourceRefsJSON string `gorm:"type:text" json:"source_refs_json"`
CreatedByRunID *uint `gorm:"index" json:"created_by_run_id"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
func (WorkerArtifact) TableName() string { return "worker_artifact" }
@@ -0,0 +1,23 @@
package model
import "time"
// WorkerRun 专员动作执行记录
type WorkerRun struct {
ID uint `gorm:"primaryKey" json:"id"`
TaskID uint `gorm:"not null;index" json:"task_id"`
SpecialistKey string `gorm:"size:64;not null;index" json:"specialist_key"`
ActionKey string `gorm:"size:64;not null;index" json:"action_key"`
ActionTitle string `gorm:"size:128;not null" json:"action_title"`
ActionType string `gorm:"size:32;default:''" json:"action_type"`
Status string `gorm:"size:16;not null;default:done;index" json:"status"`
InputJSON string `gorm:"type:text" json:"input_json"`
OutputJSON string `gorm:"type:text" json:"output_json"`
LogsJSON string `gorm:"type:text" json:"logs_json"`
StartedAt time.Time `json:"started_at"`
FinishedAt *time.Time `json:"finished_at"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
func (WorkerRun) TableName() string { return "worker_run" }
@@ -0,0 +1,24 @@
package model
import "time"
// WorkerTask 专员事项/任务
type WorkerTask struct {
ID uint `gorm:"primaryKey" json:"id"`
SpecialistKey string `gorm:"size:64;not null;index" json:"specialist_key"`
Title string `gorm:"size:128;not null" json:"title"`
Summary string `gorm:"type:text" json:"summary"`
Owner string `gorm:"size:64;default:''" json:"owner"`
Priority string `gorm:"size:16;not null;default:P2" json:"priority"`
Status string `gorm:"size:32;not null;default:待处理;index" json:"status"`
ContextJSON string `gorm:"type:text" json:"context_json"`
CurrentRunID *uint `gorm:"index" json:"current_run_id"`
CurrentResult string `gorm:"type:text" json:"current_result"`
DueAt *time.Time `json:"due_at"`
CreatedBy *uint `gorm:"index" json:"created_by"`
LastTriggeredAt *time.Time `json:"last_triggered_at"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
func (WorkerTask) TableName() string { return "worker_task" }