Подготовить HY2XS к production-сборке

This commit is contained in:
2026-04-25 23:13:12 +05:00
commit 84a4e94567
277 changed files with 26513 additions and 0 deletions
+46
View File
@@ -0,0 +1,46 @@
package vo
import (
"github.com/gin-gonic/gin"
"hy2xs-admin/model/constant"
"net/http"
)
type result struct {
Code int `json:"code"`
Type string `json:"type"`
Message string `json:"message"`
Data interface{} `json:"data"`
}
const (
TypeSuccess = "ok"
TypeError = "no"
)
func Success(data interface{}, c *gin.Context) {
c.JSON(http.StatusOK, result{
Code: constant.CodeSuccess,
Type: TypeSuccess,
Data: data,
})
}
func Fail(message string, c *gin.Context) {
var code int
if constant.UnauthorizedError == message {
code = constant.CodeUnauthorizedError
} else if constant.ForbiddenError == message {
code = constant.CodeForbiddenError
} else if constant.InvalidError == message {
code = constant.CodeInvalidError
} else {
code = constant.CodeSysError
}
c.JSON(http.StatusOK, result{
Code: code,
Type: TypeError,
Message: message,
Data: nil,
})
}