init: initial commit

This commit is contained in:
Blizzard
2026-04-01 14:09:33 +08:00
commit aef2e152dc
66 changed files with 6540 additions and 0 deletions
+16
View File
@@ -0,0 +1,16 @@
package models
import "time"
// Entry is a single Q&A row in a knowledge library .db file.
type Entry struct {
ID uint `gorm:"primaryKey;autoIncrement" json:"id"`
Keyword string `gorm:"index;size:255;not null" json:"keyword"`
Question string `gorm:"type:text;not null" json:"question"`
Answer string `gorm:"type:text;not null" json:"answer"`
Category string `gorm:"size:100;default:'通用'" json:"category"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
func (Entry) TableName() string { return "entries" }
+25
View File
@@ -0,0 +1,25 @@
package models
import "time"
// AppSetting is a key-value store for global application settings
// (AI provider, endpoint, API key, etc.) in settings.db.
type AppSetting struct {
Key string `gorm:"primaryKey;size:100" json:"key"`
Value string `gorm:"type:text" json:"value"`
}
func (AppSetting) TableName() string { return "app_settings" }
// Library represents a registered knowledge library in settings.db.
// Each library is a separate SQLite file.
type Library struct {
ID uint `gorm:"primaryKey;autoIncrement" json:"id"`
Name string `gorm:"uniqueIndex;size:100;not null" json:"name"`
Description string `gorm:"size:255" json:"description"`
FilePath string `gorm:"size:1024;not null" json:"file_path"`
EntryCount int `gorm:"-" json:"entry_count"` // populated on read
CreatedAt time.Time `json:"created_at"`
}
func (Library) TableName() string { return "libraries" }