增加相关功能

This commit is contained in:
2026-09-03 17:54:49 +08:00
parent 44a03186da
commit d8936d9730
30 changed files with 4503 additions and 2412 deletions
+17
View File
@@ -0,0 +1,17 @@
package models
import "time"
// BackendAiChatMessage AI聊天消息表
type BackendAiChatMessage struct {
ID uint64 `orm:"column(id);pk;auto" json:"id"`
TenantID string `orm:"column(tenant_id);size(64)" json:"tenant_id"`
SessionID uint64 `orm:"column(session_id)" json:"session_id"`
Role string `orm:"column(role);size(20)" json:"role"` // user / assistant
Content string `orm:"column(content);type(text)" json:"content"`
CreateTime time.Time `orm:"column(create_time);auto_now_add;type(datetime)" json:"create_time"`
}
func (m *BackendAiChatMessage) TableName() string {
return "yz_backend_ai_chat_message"
}
+20
View File
@@ -0,0 +1,20 @@
package models
import "time"
// BackendAiChatPreset AI聊天角色预设表(用户级)
type BackendAiChatPreset struct {
ID uint64 `orm:"column(id);pk;auto" json:"id"`
TenantID string `orm:"column(tenant_id);size(64)" json:"tenant_id"`
UserID uint64 `orm:"column(user_id);default(0)" json:"user_id"`
Name string `orm:"column(name);size(100)" json:"name"`
Content string `orm:"column(content);type(text)" json:"content"`
IsDefault int8 `orm:"column(is_default);default(0)" json:"is_default"` // 0-否 1-是
CreateTime time.Time `orm:"column(create_time);auto_now_add;type(datetime)" json:"create_time"`
UpdateTime time.Time `orm:"column(update_time);auto_now;type(datetime)" json:"update_time"`
DeleteTime *time.Time `orm:"column(delete_time);type(datetime);null" json:"delete_time"`
}
func (m *BackendAiChatPreset) TableName() string {
return "yz_backend_ai_chat_preset"
}
+19
View File
@@ -0,0 +1,19 @@
package models
import "time"
// BackendAiChatSession AI聊天会话表
type BackendAiChatSession struct {
ID uint64 `orm:"column(id);pk;auto" json:"id"`
TenantID string `orm:"column(tenant_id);size(64)" json:"tenant_id"`
UserID uint64 `orm:"column(user_id);default(0)" json:"user_id"`
ProviderID uint64 `orm:"column(provider_id);default(0)" json:"provider_id"`
Title string `orm:"column(title);size(200)" json:"title"`
CreateTime time.Time `orm:"column(create_time);auto_now_add;type(datetime)" json:"create_time"`
UpdateTime time.Time `orm:"column(update_time);auto_now;type(datetime)" json:"update_time"`
DeleteTime *time.Time `orm:"column(delete_time);type(datetime);null" json:"delete_time"`
}
func (m *BackendAiChatSession) TableName() string {
return "yz_backend_ai_chat_session"
}
+26
View File
@@ -0,0 +1,26 @@
package models
import "time"
// BackendAiProvider AI接入配置表(租户隔离)
type BackendAiProvider struct {
ID uint64 `orm:"column(id);pk;auto" json:"id"`
TenantID string `orm:"column(tenant_id);size(64)" json:"tenant_id"`
UserID uint64 `orm:"column(user_id);default(0)" json:"user_id"`
ProviderType string `orm:"column(provider_type);size(20)" json:"provider_type"` // openai / anthropic
Name string `orm:"column(name);size(100)" json:"name"`
ApiBase string `orm:"column(api_base);size(255)" json:"api_base"`
ApiKey string `orm:"column(api_key);size(255)" json:"api_key"`
Models string `orm:"column(models);type(text)" json:"-"` // JSON数组存储,如 ["gpt-4o","gpt-3.5-turbo"]
ModelsList []string `orm:"-" json:"models"` // 返回给前端的模型列表
IsDefault int8 `orm:"column(is_default);default(0)" json:"is_default"` // 0-否 1-是(租户默认模型,用于智能添加等企业级功能)
Status int8 `orm:"column(status);default(1)" json:"status"` // 0-禁用 1-启用
Remark string `orm:"column(remark);size(255)" json:"remark"`
CreateTime time.Time `orm:"column(create_time);auto_now_add;type(datetime)" json:"create_time"`
UpdateTime time.Time `orm:"column(update_time);auto_now;type(datetime)" json:"update_time"`
DeleteTime *time.Time `orm:"column(delete_time);type(datetime);null" json:"delete_time"`
}
func (m *BackendAiProvider) TableName() string {
return "yz_backend_ai_provider"
}
+4
View File
@@ -77,6 +77,10 @@ func Init(_ string) {
new(ErpAccountSet),
new(ErpNormalSetting),
new(ErpCompanyContact),
new(BackendAiProvider),
new(BackendAiChatSession),
new(BackendAiChatMessage),
new(BackendAiChatPreset),
new(CmsArticleCategory),
new(CmsArticle),