api

package
v0.0.0-...-3030a97 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

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
	Msg     string
}

func (*Api) AddError

func (e *Api) AddError(err error)

AddError 添加错误

func (Api) Custom

func (e Api) Custom(httpCode int, jsonObj any)

Custom 自定义内容响应

func (Api) Error

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

Error 通常错误数据处理

func (Api) GetOrm

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

GetOrm 获取Orm DB

func (*Api) MakeContext

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

MakeContext 设置context

func (*Api) MakeOrm

func (e *Api) MakeOrm() *Api

MakeOrm 设置Orm DB

func (*Api) MakeService

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

MakeService 设置服务Log、Orm

func (Api) Success

func (e Api) Success(msg string, data any)

Success 成功数据处理

Jump to

Keyboard shortcuts

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