show sql error message

This commit is contained in:
RockYang
2024-08-05 16:14:44 +08:00
parent 3f0252b498
commit 72b1515b68
22 changed files with 115 additions and 130 deletions

View File

@@ -259,10 +259,9 @@ func (h *ChatHandler) RemoveChat(c *gin.Context) {
// RemoveMessage 删除聊天记录
func (h *ChatHandler) RemoveMessage(c *gin.Context) {
id := h.GetInt(c, "id", 0)
tx := h.DB.Unscoped().Where("id = ?", id).Delete(&model.ChatMessage{})
if tx.Error != nil {
logger.Error("error with update database", tx.Error)
resp.ERROR(c, "更新数据库失败!")
err := h.DB.Unscoped().Where("id = ?", id).Delete(&model.ChatMessage{}).Error
if err != nil {
resp.ERROR(c, err.Error())
return
}
resp.SUCCESS(c)