12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- 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,
- },
- })
- }
|