From af6a00ee4714dfd4f1bb914c2f34ea5568a729ac Mon Sep 17 00:00:00 2001 From: huang <1724659546@qq.com> Date: Thu, 23 Oct 2025 11:52:08 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/app/controller/management/controller_helpers.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/internal/app/controller/management/controller_helpers.go b/internal/app/controller/management/controller_helpers.go index a37bd27..e4bc122 100644 --- a/internal/app/controller/management/controller_helpers.go +++ b/internal/app/controller/management/controller_helpers.go @@ -2,6 +2,7 @@ package management import ( "errors" + "fmt" "strconv" "git.huangwc.com/pig/pig-farm-controller/internal/app/controller" @@ -25,7 +26,7 @@ func mapAndSendError(c *PigBatchController, ctx *gin.Context, action string, err controller.SendErrorWithAudit(ctx, controller.CodeConflict, err.Error(), action, err.Error(), id) } else { c.logger.Errorf("操作[%s]业务逻辑失败: %v", action, err) - controller.SendErrorWithAudit(ctx, controller.CodeInternalError, "操作失败", action, err.Error(), id) + controller.SendErrorWithAudit(ctx, controller.CodeInternalError, fmt.Sprintf("操作失败: %v", err), action, err.Error(), id) } } @@ -156,7 +157,7 @@ func handleAPIRequestWithResponse[Req any, Resp any]( ) { // 1. 绑定请求体 if err := ctx.ShouldBindJSON(&reqDTO); err != nil { - controller.SendErrorWithAudit(ctx, controller.CodeBadRequest, "无效的请求体", action, "请求体绑定失败", reqDTO) + controller.SendErrorWithAudit(ctx, controller.CodeBadRequest, fmt.Sprintf("无效的请求体: %v", err), action, fmt.Sprintf("请求体绑定失败: %v", err), reqDTO) return }