Documentation ¶
Index ¶
- func CamelString(s string) string
- func CompareStringSlice(a, b []string) bool
- func EF(err error)
- func GenHash(src string) string
- func GenPassHash(src string) (hashStr, salt string)
- func GenTraceId(ip string) (traceId string)
- func GetLocalIPs() (ips []net.IP)
- func IsExsitItem(v interface{}, s interface{}) bool
- func IsValidPasswd(passStr, salt, passHash string) bool
- func MapToStruct(mapData map[string]interface{}, structData interface{}) error
- func Response(c *gin.Context, code RespCode, httpCode int, data interface{}, ...)
- func ResponseAuthMiddlerwareError(c *gin.Context, errorContent string)
- func ResponseCacheError(c *gin.Context, errorContent string)
- func ResponseCasbinApiError(c *gin.Context, errorContent string)
- func ResponseClientError(c *gin.Context, errorContent string)
- func ResponseCorsMiddlewareError(c *gin.Context, errorContent string)
- func ResponseEmptyResult(c *gin.Context, errorContent string)
- func ResponseHandlerError(c *gin.Context, errorContent string)
- func ResponseInvalidParam(c *gin.Context, errorContent string)
- func ResponseMethodNotAllowed(c *gin.Context, errorContent string)
- func ResponseModelError(c *gin.Context, errorContent string)
- func ResponseOk(c *gin.Context, data interface{})
- func ResponseRbacMiddlewareError(c *gin.Context, errorContent string)
- func ResponseRepositoryError(c *gin.Context, errorContent string)
- func ResponseServerError(c *gin.Context, errorContent string)
- func ResponseUnAuthorized(c *gin.Context, errorContent string)
- func SnakeString(s string) string
- func StructToMap(structData interface{}) map[string]interface{}
- func Unzip(zipFile string, destDir string) error
- func Zip(srcFile string, destZip string) error
- type RespCode
- type RespStruct
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CompareStringSlice ¶
判断量字符串切片是否相等 如其他类型可用:reflect.DeepEqual(a, b)
func GenTraceId ¶
func GetLocalIPs ¶
func MapToStruct ¶
func ResponseAuthMiddlerwareError ¶
auth middleware error response
func ResponseCacheError ¶
cache error response
func ResponseCasbinApiError ¶
casbin api error response
func ResponseClientError ¶
客户端错误响应的封装 (http 400)
func ResponseCorsMiddlewareError ¶
cors middleware error response
func ResponseEmptyResult ¶
返回空结果或查询不到结果
func ResponseHandlerError ¶
handler error response
func ResponseInvalidParam ¶
参数校验错误响应体封装
func ResponseMethodNotAllowed ¶
访问方法不被允许
func ResponseModelError ¶
model error response
func ResponseRbacMiddlewareError ¶
rbac middleware error response
func ResponseRepositoryError ¶
repository error response
func ResponseServerError ¶
服务端错误响应的封装 (http 500)
func StructToMap ¶
func StructToMap(structData interface{}) map[string]interface{}
Types ¶
type RespCode ¶
type RespCode int
const ( ResponseCodeOk RespCode = iota ResponseCodeClientError ResponseCodeServerError ResponseCodeInvalidParam ResponseCodeUnAuthorized ResponseCodeMethodNotAllowed ResponseCodeEmptyResult ResponseCodeHandlerError ResponseCodeModelError ResponseCodeRepositoryError ResponseCodeCacheError ResponseCodeCasbinError ResponseCodeAuthMiddlerwareError ResponseCodeCorsMiddlerwareError ResponseCodeRbacMiddlerwareError )
定义用户级别的返回码,并枚举其信息输出
type RespStruct ¶
type RespStruct struct { Code RespCode `json:"code"` Msg string `json:"message"` Error string `json:"error"` Data interface{} `json:"data"` }
统一返回消息体
Source Files ¶
Click to show internal directories.
Click to hide internal directories.