26 lines
462 B
Go
26 lines
462 B
Go
|
package common
|
||
|
|
||
|
import (
|
||
|
"github.com/gin-gonic/gin"
|
||
|
"net/http"
|
||
|
)
|
||
|
|
||
|
func SuccessMsg(c *gin.Context, msg string) {
|
||
|
c.JSON(http.StatusOK, gin.H{
|
||
|
"msg": msg,
|
||
|
"code": http.StatusOK,
|
||
|
})
|
||
|
}
|
||
|
|
||
|
func SuccessData(c *gin.Context, data any) {
|
||
|
c.JSON(http.StatusOK, data)
|
||
|
}
|
||
|
|
||
|
func SuccessDataWithErrorMsg(c *gin.Context, data any, err error) {
|
||
|
c.JSON(http.StatusUnprocessableEntity, gin.H{
|
||
|
"data": data,
|
||
|
"msg": err,
|
||
|
"code": http.StatusInternalServerError,
|
||
|
})
|
||
|
}
|