From 2c9874a1801e3e5d0c80ad5a72a9b86e1445e34d Mon Sep 17 00:00:00 2001 From: wolter <11@gmail> Date: Mon, 8 Dec 2025 14:33:32 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E4=BC=9A=E8=AF=9D=E5=8E=86=E5=8F=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/entitys/chat_history.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/internal/entitys/chat_history.go b/internal/entitys/chat_history.go index 6991a53..019a8c6 100644 --- a/internal/entitys/chat_history.go +++ b/internal/entitys/chat_history.go @@ -4,6 +4,7 @@ import ( "ai_scheduler/internal/data/constants" "ai_scheduler/internal/data/model" "encoding/json" + "log" ) type ChatHistory struct { @@ -33,7 +34,7 @@ type ChatHisQueryResponse struct { CreateAt string `gorm:"column:create_at;default:CURRENT_TIMESTAMP" json:"create_at"` TaskID int32 `gorm:"column:task_id;not null" json:"task_id"` // 任务ID TaskName string `gorm:"column:task_name;not null" json:"task_name"` // 任务名称 - Content []string `gorm:"column:content" json:"content"` // 前端回传数据 + Contents []string `gorm:"column:contents" json:"contents"` // 前端回传数据 } func (c *ChatHisQueryResponse) FromModel(chat model.AiChatHi, task model.AiTask) { @@ -46,15 +47,15 @@ func (c *ChatHisQueryResponse) FromModel(chat model.AiChatHi, task model.AiTask) c.CreateAt = chat.CreateAt.Format("2006-01-02 15:04:05") c.TaskID = chat.TaskID c.TaskName = task.Name - c.Content = make([]string, 0) + c.Contents = make([]string, 0) // 解析Content if "" != chat.Content { - var contents []string - if err := json.Unmarshal([]byte(chat.Content), &contents); err != nil { - c.Content = contents + err := json.Unmarshal([]byte(chat.Content), &c.Contents) + if err != nil { + c.Contents = append(c.Contents, chat.Content) + log.Println("解析Content失败 error: ", err) } - c.Content = append(c.Content, chat.Content) } }