diff --git a/curd/curd.go b/curd/curd.go index 2f67213..45051cd 100644 --- a/curd/curd.go +++ b/curd/curd.go @@ -455,7 +455,7 @@ func (c Curd[R]) Count(ctx ctx, where any) (count int64) { // -------------------------- 原Save对应实现:新增/更新记录(对应GORM的Save) -------------------------- func (c Curd[R]) Save(ctx ctx, data any) { - err := c.Dao.Ctx(ctx).Model(new(R)).Save(data).Error + err := c.Dao.Ctx(ctx).Model(new(R)).Create(data).Error if err != nil { panic(fmt.Sprintf("Save保存错误: %v", err)) } diff --git a/middleware/middleware.go b/middleware/middleware.go index d4b142b..0cc9ab2 100644 --- a/middleware/middleware.go +++ b/middleware/middleware.go @@ -12,8 +12,8 @@ func ErrorHandler() gin.HandlerFunc { return func(c *gin.Context) { defer func() { if err := recover(); err != nil { - log.Error("发生panic", "path", c.Request.URL.Path, "method", c.Request.Method, err) - response.Error(c).SetCode(http.StatusInternalServerError).SetMsg("服务器内部错误").End() + log.Error("发生panic=》", "path:", c.Request.URL.Path, ",method:", c.Request.Method, ",", err) + response.Error(c).SetCode(http.StatusInternalServerError).SetMsg(err.(error).Error()).End() c.Abort() } }()