package utils

import (
	"github.com/gin-gonic/gin"
	"net/http"
)

type Response struct {
	Code int         `json:"code"` // if request is success
	Msg  string      `json:"msg"`
	Data interface{} `json:"data"` // response data
}

func ResponseOK(c *gin.Context, errMsg string, data interface{}) {
	c.JSON(http.StatusOK, Response{
		Code: 0,
		Msg:  errMsg,
		Data: data,
	})
	return
}

func ResponseError(c *gin.Context, errMsg string, data interface{}) {
	c.JSON(http.StatusOK, Response{
		Code: 400,
		Msg:  errMsg,
		Data: data,
	})
	return
}
