2024-06-16 06:16:59 +00:00
|
|
|
package helper
|
2024-06-13 08:36:10 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/gin-gonic/gin"
|
2024-07-14 17:22:40 +00:00
|
|
|
"leafdev.top/leaf/rag/models"
|
2024-06-13 08:36:10 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func ResponseMessage(c *gin.Context, code int, message string, data interface{}) {
|
2024-07-14 17:22:40 +00:00
|
|
|
c.JSON(code, &models.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-07-14 17:22:40 +00:00
|
|
|
c.JSON(code, &models.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-07-14 17:22:40 +00:00
|
|
|
c.JSON(code, &models.BaseResponse{
|
2024-06-13 08:36:10 +00:00
|
|
|
Error: err.Error(),
|
|
|
|
Code: code,
|
|
|
|
})
|
|
|
|
c.Abort()
|
|
|
|
|
|
|
|
}
|