api

package
v1.6.4 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2023 License: Apache-2.0 Imports: 24 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) Data

func (e *Api) Data(data interface{})

func (*Api) Fail

func (e *Api) Fail(msgCode int, message ...string)

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) MakeModel

func (e *Api) MakeModel(mm ...*model.Model) *Api

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(result interface{})

func (*Api) Page

func (e *Api) Page(total int64, pageSize int, pageIndex int, rows interface{})

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