package e

import (
	"github.com/gin-gonic/gin"
	"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,
	})
}
