beancount-gs/service/error.go

31 lines
761 B
Go
Raw Normal View History

2021-11-18 08:27:28 +00:00
package service
import (
"github.com/gin-gonic/gin"
"net/http"
)
2021-11-21 14:37:13 +00:00
func OK(c *gin.Context, data interface{}) {
2021-11-18 08:27:28 +00:00
c.JSON(http.StatusOK, gin.H{"code": 200, "message": "ok", "data": data})
}
func BadRequest(c *gin.Context, message string) {
2021-11-18 10:10:19 +00:00
c.JSON(http.StatusOK, gin.H{"code": 400, "message": message})
}
func Unauthorized(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{"code": 401})
2021-11-18 08:27:28 +00:00
}
func InternalError(c *gin.Context, message string) {
2021-11-18 10:10:19 +00:00
c.JSON(http.StatusOK, gin.H{"code": 500, "message": message})
2021-11-18 08:27:28 +00:00
}
func LedgerIsNotExist(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{"code": 1006, "message": "ledger is not exist"})
}
func LedgerIsNotAllowAccess(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{"code": 1006, "message": "ledger is not allow access"})
}