refactor(web): restructure Vue3 app layout
This commit is contained in:
86
memora-api/internal/model/model.go
Normal file
86
memora-api/internal/model/model.go
Normal file
@@ -0,0 +1,86 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
type Word struct {
|
||||
ID int64 `json:"id" gorm:"primaryKey"`
|
||||
Word string `json:"word" gorm:"size:100;uniqueIndex;not null"`
|
||||
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"`
|
||||
PartOfSpeech string `json:"part_of_speech" gorm:"size:50"`
|
||||
Definition string `json:"definition" gorm:"type:text"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
}
|
||||
|
||||
func (Word) TableName() string {
|
||||
return "words"
|
||||
}
|
||||
|
||||
type MemoryRecord struct {
|
||||
ID int64 `json:"id" gorm:"primaryKey"`
|
||||
WordID int64 `json:"word_id" gorm:"index;not null"`
|
||||
UserID int64 `json:"user_id" gorm:"index;default:1"`
|
||||
CorrectCount int `json:"correct_count" gorm:"default:0"`
|
||||
TotalCount int `json:"total_count" gorm:"default:0"`
|
||||
MasteryLevel int `json:"mastery_level" gorm:"default:0"`
|
||||
LastReviewedAt *time.Time `json:"last_reviewed_at"`
|
||||
NextReviewAt *time.Time `json:"next_review_at" gorm:"index"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
Word *Word `json:"word,omitempty" gorm:"foreignKey:WordID"`
|
||||
}
|
||||
|
||||
func (MemoryRecord) TableName() string {
|
||||
return "memory_records"
|
||||
}
|
||||
|
||||
// 请求响应结构
|
||||
type AddWordRequest struct {
|
||||
Word string `json:"word" binding:"required"`
|
||||
}
|
||||
|
||||
type ReviewAnswerRequest struct {
|
||||
RecordID int64 `json:"record_id" binding:"required"`
|
||||
Answer string `json:"answer" binding:"required"`
|
||||
Mode string `json:"mode" binding:"required"` // spelling, en2cn, cn2en
|
||||
}
|
||||
|
||||
type ReviewResult struct {
|
||||
Word *Word `json:"word"`
|
||||
Correct bool `json:"correct"`
|
||||
Answer string `json:"answer"`
|
||||
CorrectAns string `json:"correct_ans,omitempty"`
|
||||
}
|
||||
|
||||
// 有道API响应 (标准API)
|
||||
type YoudaoResponse struct {
|
||||
Query string `json:"query"`
|
||||
Translation []string `json:"translation"`
|
||||
Basic struct {
|
||||
Phonetic string `json:"phonetic"`
|
||||
UkPhonetic string `json:"uk-phonetic"`
|
||||
UsPhonetic string `json:"us-phonetic"`
|
||||
ExamType []string `json:"exam_type"`
|
||||
Wfs []struct {
|
||||
Wf struct {
|
||||
Name string `json:"name"`
|
||||
} `json:"wf"`
|
||||
Means []struct {
|
||||
Mean struct {
|
||||
Text string `json:"text"`
|
||||
} `json:"mean"`
|
||||
} `json:"means"`
|
||||
} `json:"wfs"`
|
||||
} `json:"basic"`
|
||||
SpeakUrl string `json:"speakUrl"`
|
||||
SpeakFile string `json:"speakFile"`
|
||||
Web []struct {
|
||||
Value []string `json:"value"`
|
||||
} `json:"web"`
|
||||
ErrorCode string `json:"errorCode"`
|
||||
}
|
||||
Reference in New Issue
Block a user