package controller import ( "github.com/gin-gonic/gin" "net/http" ) type Controller struct { } func (c *Controller) ResponseErr(ctx *gin.Context, err error) { ctx.JSON(http.StatusOK, gin.H{ "code": http.StatusInternalServerError, "msg": err.Error(), }) } func (c *Controller) ResponseErrParam(ctx *gin.Context) { ctx.JSON(http.StatusOK, gin.H{ "code": http.StatusBadRequest, "msg": "请求参数错误", }) } func (c *Controller) ResponseOk(ctx *gin.Context) { ctx.JSON(http.StatusOK, gin.H{ "code": http.StatusOK, "msg": "ok", }) }