01ecdc8c23
- Go module with standard library + gorilla/sessions + mysql driver - Config: env-based configuration with .env file support - Database: MySQL connection with auto-migration for 6 tables - Seed data: 12 system tags with options, 8 system snippets - Auth: session cookie middleware - Handlers: auth, tags, snippets, builder, claude, dashboard, suggestions, settings - LLM: OpenAI-compatible client with 30s timeout - Docker: Dockerfile + docker-compose.yml - .env.example with all configuration options Co-Authored-By: Claude <noreply@anthropic.com>
92 lines
2.6 KiB
Go
92 lines
2.6 KiB
Go
package models
|
|
|
|
import "time"
|
|
|
|
// Tag 标签定义
|
|
type Tag struct {
|
|
ID int64 `json:"id"`
|
|
Name string `json:"name"`
|
|
Description string `json:"description"`
|
|
Scope string `json:"scope"` // system or personal
|
|
CreatedAt time.Time `json:"created_at"`
|
|
Options []TagOption `json:"options,omitempty"`
|
|
}
|
|
|
|
// TagOption 标签选项
|
|
type TagOption struct {
|
|
ID int64 `json:"id"`
|
|
TagID int64 `json:"tag_id"`
|
|
Label string `json:"label"`
|
|
ConstraintText string `json:"constraint_text"`
|
|
SortOrder int `json:"sort_order"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
}
|
|
|
|
// Snippet 片段模板
|
|
type Snippet struct {
|
|
ID int64 `json:"id"`
|
|
Name string `json:"name"`
|
|
Content string `json:"content"`
|
|
Category string `json:"category"`
|
|
Scope string `json:"scope"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
}
|
|
|
|
// BuilderSession 构建会话
|
|
type BuilderSession struct {
|
|
ID int64 `json:"id"`
|
|
Title string `json:"title"`
|
|
ProjectName string `json:"project_name"`
|
|
FinalPrompt string `json:"final_prompt"`
|
|
ClaudeSessionID *string `json:"claude_session_id"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
Tags []SessionTag `json:"tags,omitempty"`
|
|
Snippets []SessionSnippet `json:"snippets,omitempty"`
|
|
}
|
|
|
|
// SessionTag 构建会话标签关联
|
|
type SessionTag struct {
|
|
ID int64 `json:"id"`
|
|
BuilderSessionID int64 `json:"builder_session_id"`
|
|
TagID int64 `json:"tag_id"`
|
|
TagOptionID int64 `json:"tag_option_id"`
|
|
}
|
|
|
|
// SessionSnippet 构建会话片段关联
|
|
type SessionSnippet struct {
|
|
ID int64 `json:"id"`
|
|
BuilderSessionID int64 `json:"builder_session_id"`
|
|
SnippetID int64 `json:"snippet_id"`
|
|
SortOrder int `json:"sort_order"`
|
|
}
|
|
|
|
// Prompt prompts 表记录(只读)
|
|
type Prompt struct {
|
|
ID int64 `json:"id"`
|
|
SessionID string `json:"session_id"`
|
|
ProjectName string `json:"project_name"`
|
|
Prompt string `json:"prompt"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
}
|
|
|
|
// Suggestion 智能建议
|
|
type Suggestion struct {
|
|
Title string `json:"title"`
|
|
Description string `json:"description"`
|
|
ConstraintText string `json:"constraint_text"`
|
|
}
|
|
|
|
// Settings 系统设置
|
|
type Settings struct {
|
|
LLMAPIBaseURL string `json:"llm_api_base_url"`
|
|
LLMModelName string `json:"llm_model_name"`
|
|
}
|
|
|
|
// APIResponse 统一响应
|
|
type APIResponse struct {
|
|
Code int `json:"code"`
|
|
Message string `json:"message"`
|
|
Data interface{} `json:"data,omitempty"`
|
|
}
|