util

package
v0.0.0-...-482afe4 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2022 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SUCCESS = 1  //成功
	ZERO    = 0  //0值
	ERROR   = -1 //失败
)

appRes 系统通用返回

Variables

View Source
var Validate *validator.Validate

全局验证实例

Functions

func CheckErr

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

func FileExist

func FileExist(file string) bool

目录 or 文件 是否存在

func ResError

func ResError(c *gin.Context, msg string, res int, data interface{})

func ResSuccess

func ResSuccess(c *gin.Context, data interface{}, msg string)

func ResSuccessList

func ResSuccessList(c *gin.Context, dataList interface{}, pagination Pagination, msg string)

Types

type AppError

type AppError struct {
	Err  error
	Code int
}

appError 系统通用error

func AppErrorNew

func AppErrorNew(err error, code int) *AppError

func (*AppError) Error

func (a *AppError) Error() string

func (*AppError) GetCode

func (a *AppError) GetCode() int

type Pagination

type Pagination struct {
	TotalCount int64 `json:"total_count"`
	Page       int   `json:"page"`
	PerPage    int   `json:"per_page"`
}

分页

type Res

type Res struct {
	Data interface{} `json:"data"`
	Res  int         `json:"res"`
	Msg  string      `json:"msg"`
}

Jump to

Keyboard shortcuts

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