package utils import ( "mtp20access/model/common/response" "github.com/gin-gonic/gin" ) type GinUtils struct { C *gin.Context err error } // BindFormReq 绑定Form入参的方法 func (r *GinUtils) BindFormReq(req interface{}) { if r.err != nil { return } if r.err = r.C.ShouldBind(&req); r.err != nil { response.FailWithMessage("入参不正确", r.C) return } } // BindJsonReq 绑定Body入参的方法 func (r *GinUtils) BindJsonReq(req interface{}) { if r.err != nil { return } if r.err = r.C.ShouldBindJSON(&req); r.err != nil { response.FailWithMessage("入参不正确", r.C) return } }