common

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2022 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetMsg

func GetMsg(code RetCode) string

func GetValidator added in v0.1.0

func GetValidator() *validator.Validate

GetValidator gin 集成了 validator,但是标签用的是 binding,这里获取的 validator 是为标签为 validate 准备的

func InitTrans

func InitTrans(locale string) (err error)

Types

type BaseController

type BaseController struct{}

func (*BaseController) CheckParams

func (c *BaseController) CheckParams(ctx *gin.Context, params interface{}) bool

CheckParams check params, params must be a pointer

func (*BaseController) Response

func (c *BaseController) Response(ctx *gin.Context, data interface{}, err error)

type CodeWithErr added in v0.1.0

type CodeWithErr struct {
	RetCode RetCode
	Err     error
}

func NewCodeWithErr added in v0.1.0

func NewCodeWithErr(code RetCode, err error) *CodeWithErr

func (CodeWithErr) Error added in v0.1.0

func (c CodeWithErr) Error() string

type ListData

type ListData struct {
	Counts     int64       `json:"counts"`
	Data       interface{} `json:"data"`
	PageOffset int         `json:"page_offset"`
	PageLimit  int         `json:"page_limit"`
}

type Response

type Response struct {
	RetCode RetCode     `json:"ret_code"`
	Message string      `json:"message"`
	DataSet interface{} `json:"data_set"`
}

type RetCode

type RetCode int
const (
	SUCCESS   RetCode = 0
	FORBIDDEN RetCode = 4030
	FAILED    RetCode = 5000 + iota
	ErrorDatabaseRead
	ErrorDatabaseWrite
	ErrorDatabaseNotFound
	ErrInvalidParams
	ErrInvalidJSONParams
	ErrorPrivilege
	ErrorResourceNotExist
	ErrorCallOtherSrv
)

func BindAndValid

func BindAndValid(c *gin.Context, form interface{}) (RetCode, error)

Jump to

Keyboard shortcuts

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