新增响应体与请求结构绑定
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
package request
|
||||
|
||||
import (
|
||||
"apiServer_service/utils/loger"
|
||||
"fmt"
|
||||
"github.com/cloudwego/hertz/pkg/app"
|
||||
)
|
||||
|
||||
// BindRequestStruct 结构体参数绑定
|
||||
func BindRequestStruct(c *app.RequestContext, request interface{}) error {
|
||||
err := c.BindAndValidate(request)
|
||||
if err != nil {
|
||||
loger.Debug("BindRequestStruct", fmt.Sprintf("参数错误: %v", err))
|
||||
BadRequest(c, "参数错误")
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user