global

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// 全局日志变量
	Log    *zap.SugaredLogger
	Logger *zap.Logger

	// gin服务对象Logger
	Server *gin.Engine

	// 配置文件
	Cfg *config.Config

	// 鉴权对象
	Auth *jwt.GinJWTMiddleware

	// 需要自动检查创建的表
	AutoTables map[string]interface{}

	// 需要自动执行的脚本
	AutoSqls map[string]string

	// 在初始化需要执行的一些方法
	InitHandlers map[string]func()

	// 中间件
	MidHandlers map[string]gin.HandlerFunc
)
View Source
var CodeMessage = map[ResCode]string{
	OK:             "成功",
	PARAM_ERROR:    "参数错误",
	INTERNAL_ERROR: "服务器内部错误",
	INSERT_ERROR:   "新增失败",
	UPDATE_ERROR:   "更新失败",
	DELETE_ERROR:   "删除失败",
	SELECT_ERROR:   "查询失败",
	AUTH_ERROR:     "JWT认证失败",
}

Functions

func ResFail

func ResFail(ctx *gin.Context, code ResCode)

func ResSuccessFullData

func ResSuccessFullData(ctx *gin.Context, data interface{})

func ResSuccessNullData

func ResSuccessNullData(ctx *gin.Context)

func ResSuccessPageData

func ResSuccessPageData(ctx *gin.Context, data interface{})

Types

type ResBase

type ResBase struct {
	Code             ResCode `json:"code"`              // 状态码
	Message          string  `json:"message"`           // 状态消息
	RequestDatetime  string  `json:"request_datetime"`  // 请求时间
	ResponseDatetime string  `json:"response_datetime"` // 返回时间
	RequestId        string  `json:"request_id"`        // 请求ID
}

type ResCode

type ResCode int
const (
	OK             ResCode = 200
	PARAM_ERROR    ResCode = 401
	INTERNAL_ERROR ResCode = 500
	AUTH_ERROR     ResCode = 505
	INSERT_ERROR   ResCode = 10001
	UPDATE_ERROR   ResCode = 10002
	DELETE_ERROR   ResCode = 10003
	SELECT_ERROR   ResCode = 10004
)

type ResFull

type ResFull struct {
	ResBase
	Data interface{} `json:"data"` // 返回数据
}

type ResNull

type ResNull struct {
	ResBase
}

type ResPage

type ResPage struct {
	ResBase
	Page models.PageInfo `json:"pageInfo"` // 分页信息
	Data interface{}     `json:"data"`     // 返回数据
}

Jump to

Keyboard shortcuts

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