From 0a5f30b3289b32754f2d0e8d12d93687cf123ef3 Mon Sep 17 00:00:00 2001 From: wonder Date: Wed, 25 Mar 2026 21:36:49 +0800 Subject: [PATCH] =?UTF-8?q?=20=E2=9C=A8Feat:=20=E5=AE=9A=E4=B9=89card?= =?UTF-8?q?=E7=BB=93=E6=9E=84=E4=BD=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/agent/response_struct/card.go | 66 +++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 backend/agent/response_struct/card.go diff --git a/backend/agent/response_struct/card.go b/backend/agent/response_struct/card.go new file mode 100644 index 0000000..4ed0176 --- /dev/null +++ b/backend/agent/response_struct/card.go @@ -0,0 +1,66 @@ +package agent + +// Card 是顶层结构体,包含所有关于 Go map 的笔记内容 +type Card struct { + Summary string `json:"summary"` + KeyPoints KeyPoints `json:"key_points"` + CommonMisconceptions CommonMisconceptions `json:"common_misconceptions"` + BestPractices BestPractices `json:"best_practices"` + Mnemonic Mnemonic `json:"mnemonic"` +} + +// KeyPoints 包含关键要点部分 +type KeyPoints struct { + Header string `json:"header"` + Items []KeyPointItem `json:"items"` +} + +// KeyPointItem 是关键要点的单个条目 +type KeyPointItem struct { + Point string `json:"point"` + Description string `json:"description"` +} + +// CommonMisconceptions 包含常见误区部分 +type CommonMisconceptions struct { + Header string `json:"header"` + Items []MisconceptionItem `json:"items"` +} + +// MisconceptionItem 是常见误区的单个条目 +type MisconceptionItem struct { + ID string `json:"id"` + Title string `json:"title"` + Detail string `json:"detail"` + Fix string `json:"fix"` +} + +// BestPractices 包含最佳实践部分 +type BestPractices struct { + Header string `json:"header"` + Items []PracticeItem `json:"items"` +} + +// PracticeItem 是最佳实践的单个条目 +type PracticeItem struct { + ID string `json:"id"` + Title string `json:"title"` + Detail string `json:"detail"` + CorrectExample string `json:"correct_example,omitempty"` // 可能不存在于某些条目 + IncorrectExample string `json:"incorrect_example,omitempty"` // 可能不存在于某些条目 +} + +// Mnemonic 包含记忆口诀部分 +type Mnemonic struct { + Header string `json:"header"` + Content string `json:"content"` +} + +// 使用示例: +// var card Card +// err := json.Unmarshal(data, &card) +// 或 +// wrapper := struct { +// Card Card `json:"card"` +// }{} +// err := json.Unmarshal(data, &wrapper) \ No newline at end of file