common

package
v0.0.0-...-12c2583 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 15, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

README

通用工具

把公共的函数或者对象放到这个包进行定义,然后全局共用

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SendFaild

func SendFaild(c *gin.Context, err error)

发送异常消息

func ToJSON

func ToJSON(obj any) string

func Validate

func Validate(obj any) error

使用统计的校验函数

Types

type ApiException

type ApiException struct {
	// 0表示正常, nil 表示状态未知, 业务异常吗
	ErrorCode *int `json:"error_code"`
	// http 状态码
	HttpCode int `json:"http_code"`
	// 具体的异常信息
	Message string `json:"message"`
}

之定义异常实现

func NewApiException

func NewApiException(code int, message string) *ApiException

func NewUnauthorized

func NewUnauthorized() *ApiException

func (*ApiException) Error

func (e *ApiException) Error() string

func (*ApiException) SetHttpCode

func (e *ApiException) SetHttpCode(code int) *ApiException

func (*ApiException) ToJSON

func (e *ApiException) ToJSON() string

fmt Stringer

type Meta

type Meta struct {
	Id        int   `json:"id"`
	CreatedAt int64 `json:"created_at"`
	UpdatedAt int64 `json:"updated_at"`
}

func NewMate

func NewMate() *Meta

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL