package controller import ( "net/http" "xiawan/wx/api/vo" "github.com/gin-gonic/gin" ) func validateData(ctx *gin.Context, model interface{}) bool { // ShouldBindJSON err := ctx.ShouldBindJSON(&model) if err != nil { ctx.JSON(http.StatusOK, vo.DTO{ Code: vo.FAIL_DATA, Data: nil, Text: "\"提交数据错误!\"", }) ctx.Abort() return false } return true }