2024-06-15 16:55:25 +00:00
|
|
|
package helpers
|
2024-06-13 08:36:10 +00:00
|
|
|
|
|
|
|
import (
|
2024-06-15 16:55:25 +00:00
|
|
|
"framework_v2/internal/app/response"
|
2024-06-13 08:36:10 +00:00
|
|
|
"github.com/gin-gonic/gin"
|
|
|
|
)
|
|
|
|
|
|
|
|
func ResponseMessage(c *gin.Context, code int, message string, data interface{}) {
|
2024-06-15 16:55:25 +00:00
|
|
|
c.JSON(code, &response.BaseResponse{
|
2024-06-13 08:36:10 +00:00
|
|
|
Message: message,
|
|
|
|
Code: code,
|
|
|
|
Data: data,
|
|
|
|
})
|
|
|
|
c.Abort()
|
|
|
|
}
|
|
|
|
|
|
|
|
func Response(c *gin.Context, code int, data interface{}) {
|
2024-06-15 16:55:25 +00:00
|
|
|
c.JSON(code, &response.BaseResponse{
|
2024-06-13 08:36:10 +00:00
|
|
|
Code: code,
|
|
|
|
Data: data,
|
|
|
|
})
|
|
|
|
c.Abort()
|
|
|
|
}
|
|
|
|
|
|
|
|
func ResponseError(c *gin.Context, code int, err error) {
|
2024-06-15 16:55:25 +00:00
|
|
|
c.JSON(code, &response.BaseResponse{
|
2024-06-13 08:36:10 +00:00
|
|
|
Error: err.Error(),
|
|
|
|
Code: code,
|
|
|
|
})
|
|
|
|
c.Abort()
|
|
|
|
|
|
|
|
}
|