api

package
v2.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2023 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultLanguage = "zh-CN"

Functions

func GetRequestLogger

func GetRequestLogger(c *gin.Context) *logger.Helper

GetRequestLogger 获取上下文提供的日志

func SetRequestLogger

func SetRequestLogger(c *gin.Context)

SetRequestLogger 设置logger中间件

Types

type Api

type Api struct {
	Context *gin.Context
	Logger  *logger.Helper
	Orm     *gorm.DB
	Errors  error
}

func (*Api) AddError

func (e *Api) AddError(err error)

func (*Api) Bind

func (e *Api) Bind(d interface{}, bindings ...binding.Binding) *Api

Bind 参数校验

func (Api) Custom

func (e Api) Custom(data gin.H)

Custom 兼容函数

func (Api) Error

func (e Api) Error(code int, err error, msg string)

Error 通常错误数据处理

func (Api) GetLogger

func (e Api) GetLogger() *logger.Helper

GetLogger 获取上下文提供的日志

func (Api) GetOrm

func (e Api) GetOrm() (*gorm.DB, error)

GetOrm 获取Orm DB

func (*Api) MakeContext

func (e *Api) MakeContext(c *gin.Context) *Api

MakeContext 设置http上下文

func (*Api) MakeOrm

func (e *Api) MakeOrm() *Api

MakeOrm 设置Orm DB

func (*Api) MakeService

func (e *Api) MakeService(c *service.Service) *Api

func (Api) OK

func (e Api) OK(data interface{}, msg string)

OK 通常成功数据处理

func (Api) PageOK

func (e Api) PageOK(result interface{}, count int, pageIndex int, pageSize int, msg string)

PageOK 分页数据处理

func (Api) Translate

func (e Api) Translate(form, to interface{})

Jump to

Keyboard shortcuts

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