opt: optimize code for remove chat item

This commit is contained in:
RockYang
2023-08-20 19:06:18 +08:00
parent 6561b99f8f
commit 5a0f272fa8
2 changed files with 29 additions and 8 deletions

View File

@@ -66,6 +66,15 @@ func (h *ChatHandler) Remove(c *gin.Context) {
return
}
// 删除当前会话的聊天记录
res = h.db.Where("user_id = ? AND chat_id =?", user.Id, chatId).Delete(&model.ChatItem{})
if res.Error != nil {
resp.ERROR(c, "Failed to remove chat from database.")
return
}
// TODO: 是否要删除 MidJourney 绘画记录和图片文件?
// 清空会话上下文
h.App.ChatContexts.Delete(chatId)
resp.SUCCESS(c, types.OkMsg)