package e import ( "github.com/gin-gonic/gin" "lot_interlligentControl/unity" "net/http" ) type R struct { Code Rescode `json:"code"` Message any `json:"message"` Data interface{} `json:"data"` } func ResponseError(c *gin.Context, code Rescode) { c.JSON(http.StatusOK, &R{ Code: code, Message: code.GetMsg(), Data: nil, }) } func ResponseSuccess(c *gin.Context, data interface{}) { c.JSON(http.StatusOK, &R{ Code: SUCCESS, Message: SUCCESS.GetMsg(), Data: data, }) } func ResponseWithMsg(c *gin.Context, code Rescode, msg any) { c.JSON(http.StatusOK, &R{ Code: code, Message: msg, Data: nil, }) } func ResPonsePage(c *gin.Context, data interface{}, total int64, params unity.PageParams) { c.JSON(http.StatusOK, &R{ Code: SUCCESS, Message: SUCCESS.GetMsg(), Data: gin.H{ "result": data, "total": total, "page_size": params.Size, }, }) }