- 重构App.vue中的侧边栏布局,更新Logo设计为带有标识和副标题的新样式 - 调整顶部导航栏,增加标题区域显示当前路由标题和日期 - 修改菜单项配置,更新导航标签为更直观的中文描述 - 在Home.vue中替换原有的仪表板为新的Hero卡片和项目进展展示 - 更新Memory.vue中的学习界面,添加学习计划设置和多阶段学习模式 - 集成新的API端点路径,将baseURL从/api调整为/api/v1 - 调整整体视觉风格,包括颜色主题、字体家族和响应式布局 - 更新数据库模型以支持词库功能,添加相关的数据迁移和种子数据 - 调整认证系统的用户ID类型从整型到字符串的变更 - 更改前端构建工具从npm到pnpm,并更新相应的Dockerfile配置
196 lines
5.9 KiB
Go
196 lines
5.9 KiB
Go
package model
|
|
|
|
import (
|
|
"time"
|
|
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
type Word struct {
|
|
ID string `json:"id" gorm:"primaryKey;size:32"`
|
|
BookID string `json:"book_id" gorm:"size:32;index;not null"`
|
|
WordRank int `json:"word_rank" gorm:"index;default:0"`
|
|
HeadWord string `json:"head_word" gorm:"size:120;index"`
|
|
Word string `json:"word" gorm:"size:120;uniqueIndex;not null"`
|
|
SourceWordID string `json:"source_word_id" gorm:"size:64;index"`
|
|
PhoneticUK string `json:"phonetic_uk" gorm:"size:255"`
|
|
PhoneticUS string `json:"phonetic_us" gorm:"size:255"`
|
|
AudioUK string `json:"audio_uk" gorm:"size:500"`
|
|
AudioUS string `json:"audio_us" gorm:"size:500"`
|
|
UKSpeech string `json:"uk_speech" gorm:"size:255"`
|
|
USSpeech string `json:"us_speech" gorm:"size:255"`
|
|
PartOfSpeech string `json:"part_of_speech" gorm:"size:50"`
|
|
Definition string `json:"definition" gorm:"type:text"`
|
|
ExampleSentence string `json:"example_sentence" gorm:"type:text"`
|
|
RawPayload string `json:"raw_payload,omitempty" gorm:"type:longtext"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
Book *WordBook `json:"book.sql,omitempty" gorm:"foreignKey:BookID;references:ID"`
|
|
}
|
|
|
|
func (Word) TableName() string {
|
|
return "words"
|
|
}
|
|
|
|
func (w *Word) BeforeCreate(tx *gorm.DB) error {
|
|
if w.ID == "" {
|
|
w.ID = NewID()
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// WordSentence 对应 content.word.content.sentence.sentences
|
|
// sContent/sCn 以原字段命名映射。
|
|
type WordSentence struct {
|
|
ID string `json:"id" gorm:"primaryKey;size:32"`
|
|
WordID string `json:"word_id" gorm:"size:32;index;not null"`
|
|
SortOrder int `json:"sort_order" gorm:"index;default:0"`
|
|
SContent string `json:"s_content" gorm:"type:text"`
|
|
SCn string `json:"s_cn" gorm:"type:text"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
}
|
|
|
|
func (WordSentence) TableName() string {
|
|
return "word_sentences"
|
|
}
|
|
|
|
func (m *WordSentence) BeforeCreate(tx *gorm.DB) error {
|
|
if m.ID == "" {
|
|
m.ID = NewID()
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// WordTranslation 对应 content.word.content.trans
|
|
// 保存中英释义及词性信息。
|
|
type WordTranslation struct {
|
|
ID string `json:"id" gorm:"primaryKey;size:32"`
|
|
WordID string `json:"word_id" gorm:"size:32;index;not null"`
|
|
SortOrder int `json:"sort_order" gorm:"index;default:0"`
|
|
Pos string `json:"pos" gorm:"size:32"`
|
|
TranCn string `json:"tran_cn" gorm:"type:text"`
|
|
TranOther string `json:"tran_other" gorm:"type:text"`
|
|
DescCn string `json:"desc_cn" gorm:"size:64"`
|
|
DescOther string `json:"desc_other" gorm:"size:64"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
}
|
|
|
|
func (WordTranslation) TableName() string {
|
|
return "word_translations"
|
|
}
|
|
|
|
func (m *WordTranslation) BeforeCreate(tx *gorm.DB) error {
|
|
if m.ID == "" {
|
|
m.ID = NewID()
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// WordSynonym + WordSynonymItem 对应 content.word.content.syno.synos[*].hwds[*]
|
|
type WordSynonym struct {
|
|
ID string `json:"id" gorm:"primaryKey;size:32"`
|
|
WordID string `json:"word_id" gorm:"size:32;index;not null"`
|
|
SortOrder int `json:"sort_order" gorm:"index;default:0"`
|
|
Pos string `json:"pos" gorm:"size:32"`
|
|
Tran string `json:"tran" gorm:"type:text"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
}
|
|
|
|
func (WordSynonym) TableName() string {
|
|
return "word_synonyms"
|
|
}
|
|
|
|
func (m *WordSynonym) BeforeCreate(tx *gorm.DB) error {
|
|
if m.ID == "" {
|
|
m.ID = NewID()
|
|
}
|
|
return nil
|
|
}
|
|
|
|
type WordSynonymItem struct {
|
|
ID string `json:"id" gorm:"primaryKey;size:32"`
|
|
SynonymID string `json:"synonym_id" gorm:"size:32;index;not null"`
|
|
SortOrder int `json:"sort_order" gorm:"index;default:0"`
|
|
Word string `json:"word" gorm:"size:120;not null"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
}
|
|
|
|
func (WordSynonymItem) TableName() string {
|
|
return "word_synonym_items"
|
|
}
|
|
|
|
func (m *WordSynonymItem) BeforeCreate(tx *gorm.DB) error {
|
|
if m.ID == "" {
|
|
m.ID = NewID()
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// WordPhrase 对应 content.word.content.phrase.phrases
|
|
type WordPhrase struct {
|
|
ID string `json:"id" gorm:"primaryKey;size:32"`
|
|
WordID string `json:"word_id" gorm:"size:32;index;not null"`
|
|
SortOrder int `json:"sort_order" gorm:"index;default:0"`
|
|
PContent string `json:"p_content" gorm:"type:text"`
|
|
PCn string `json:"p_cn" gorm:"type:text"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
}
|
|
|
|
func (WordPhrase) TableName() string {
|
|
return "word_phrases"
|
|
}
|
|
|
|
func (m *WordPhrase) BeforeCreate(tx *gorm.DB) error {
|
|
if m.ID == "" {
|
|
m.ID = NewID()
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// WordRel + WordRelItem 对应 content.word.content.relWord.rels[*].words[*]
|
|
type WordRel struct {
|
|
ID string `json:"id" gorm:"primaryKey;size:32"`
|
|
WordID string `json:"word_id" gorm:"size:32;index;not null"`
|
|
SortOrder int `json:"sort_order" gorm:"index;default:0"`
|
|
Pos string `json:"pos" gorm:"size:32"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
}
|
|
|
|
func (WordRel) TableName() string {
|
|
return "word_rels"
|
|
}
|
|
|
|
func (m *WordRel) BeforeCreate(tx *gorm.DB) error {
|
|
if m.ID == "" {
|
|
m.ID = NewID()
|
|
}
|
|
return nil
|
|
}
|
|
|
|
type WordRelItem struct {
|
|
ID string `json:"id" gorm:"primaryKey;size:32"`
|
|
RelID string `json:"rel_id" gorm:"size:32;index;not null"`
|
|
SortOrder int `json:"sort_order" gorm:"index;default:0"`
|
|
Hwd string `json:"hwd" gorm:"size:120"`
|
|
Tran string `json:"tran" gorm:"type:text"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
}
|
|
|
|
func (WordRelItem) TableName() string {
|
|
return "word_rel_items"
|
|
}
|
|
|
|
func (m *WordRelItem) BeforeCreate(tx *gorm.DB) error {
|
|
if m.ID == "" {
|
|
m.ID = NewID()
|
|
}
|
|
return nil
|
|
}
|