fix: bind json

master
howell 3 years ago
parent d147dc6f6e
commit ce3933bd6f

@ -66,7 +66,7 @@ func QueryActivityList(c *gin.Context) {
//})
var p activityReq
err := tools.Params(&p, c)
err := tools.ParseParams(&p, c)
if err != nil {
back.Fail(c, err.Error())
return

@ -33,7 +33,7 @@ type diamondReq struct {
func QueryDiamondShow(c *gin.Context) {
var args diamondReq
err := tools.Params(&args, c)
err := tools.ParseParams(&args, c)
if err != nil {
back.Fail(c, err.Error())
return

@ -39,7 +39,7 @@ type promotionReq struct {
func QueryPromotionTimeItems(c *gin.Context) {
var p promotionReq
err := tools.Params(&p, c)
err := tools.ParseParams(&p, c)
if err != nil {
back.Fail(c, err.Error())
return

@ -60,7 +60,7 @@ func ParseParams(p interface{}, c *gin.Context) error {
func Params(p interface{}, c *gin.Context) error {
ct := strings.ToLower(c.Request.Header.Get("Content-Type"))
if strings.Contains(ct, "application/json") {
err := c.ShouldBindJSON(p)
err := c.BindJSON(p)
if err != nil {
return err
}

Loading…
Cancel
Save