show sql error message

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

View File

@@ -81,10 +81,9 @@ func (h *ChatRoleHandler) UpdateRole(c *gin.Context) {
return
}
res := h.DB.Model(&model.User{}).Where("id = ?", user.Id).UpdateColumn("chat_roles_json", utils.JsonEncode(data.Keys))
if res.Error != nil {
logger.Error("error with update database", res.Error)
resp.ERROR(c, "更新数据库失败!")
err = h.DB.Model(&model.User{}).Where("id = ?", user.Id).UpdateColumn("chat_roles_json", utils.JsonEncode(data.Keys)).Error
if err != nil {
resp.ERROR(c, err.Error())
return
}