package api import ( "github.com/gin-gonic/gin" "net/http" ) type BaseController struct { } // PageData 分页数据返回格式 type pageData struct { Limit interface{} `json:"limit"` // 分页数量 Items interface{} `json:"items"` // 数据列表 TotalCount int `json:"total"` // 总数量 } // ResponseSuccess 成功响应格式 func (b BaseController) responseSuccess(c *gin.Context, data interface{}) { c.JSON(http.StatusOK, gin.H{ "code": 200, "message": "success", "data": data, }) } // ResponseError 错误响应格式 func (b BaseController) responseError(c *gin.Context, code int, message string) { c.JSON(http.StatusOK, gin.H{ "code": code, "message": message, "data": []interface{}{}, }) }