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

@@ -276,10 +276,9 @@ func (h *DallJobHandler) Publish(c *gin.Context) {
userId := h.GetLoginUserId(c)
action := h.GetBool(c, "action") // 发布动作true => 发布false => 取消分享
res := h.DB.Model(&model.DallJob{Id: uint(id), UserId: userId}).UpdateColumn("publish", action)
if res.Error != nil {
logger.Error("error with update database", res.Error)
resp.ERROR(c, "更新数据库失败")
err := h.DB.Model(&model.DallJob{Id: uint(id), UserId: userId}).UpdateColumn("publish", action).Error
if err != nil {
resp.ERROR(c, err.Error())
return
}