33 lines
570 B
Go
33 lines
570 B
Go
|
package helper
|
||
|
|
||
|
import (
|
||
|
"framework_v2/internal/consts"
|
||
|
"github.com/gin-gonic/gin"
|
||
|
)
|
||
|
|
||
|
func ResponseMessage(c *gin.Context, code int, message string, data interface{}) {
|
||
|
c.JSON(code, &consts.BaseResponse{
|
||
|
Message: message,
|
||
|
Code: code,
|
||
|
Data: data,
|
||
|
})
|
||
|
c.Abort()
|
||
|
}
|
||
|
|
||
|
func Response(c *gin.Context, code int, data interface{}) {
|
||
|
c.JSON(code, &consts.BaseResponse{
|
||
|
Code: code,
|
||
|
Data: data,
|
||
|
})
|
||
|
c.Abort()
|
||
|
}
|
||
|
|
||
|
func ResponseError(c *gin.Context, code int, err error) {
|
||
|
c.JSON(code, &consts.BaseResponse{
|
||
|
Error: err.Error(),
|
||
|
Code: code,
|
||
|
})
|
||
|
c.Abort()
|
||
|
|
||
|
}
|