http

package
v1.3.3 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2023 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// 成功
	OK       = BgRes{Code: 200, Msg: "执行成功"}
	DeleteOK = BgRes{Code: 200, Msg: "删除成功"}
	Fail     = BgRes{Code: 500, Msg: "执行失败"}
	Has      = BgRes{Code: 500, Msg: "已存在"}
	// 参数错误
	ParamsParserError = BgRes{Code: 4000001, Msg: "参数类型不匹配,解析失败"}
	ParamsEmptyError  = BgRes{Code: 4000002, Msg: "参数不能为空"}

	// 权限错误
	LoginTimeOutError = BgRes{Code: 4010001, Msg: "登录超时"}
	UnauthorizedError = BgRes{Code: 4010003, Msg: "无权操作"}

	// 服务器错误
	InternalServerError   = BgRes{Code: 5000001, Msg: "系统异常"}
	DataFailError         = BgRes{Code: 5000002, Msg: "数据获取失败"}
	LogoutError           = BgRes{Code: 5000003, Msg: "退出失败"}
	AccountNotEnableError = BgRes{Code: 5000004, Msg: "该账户未启用,不能登录"}

	// 数据库错误
	DbConnectError = BgRes{Code: 5010001, Msg: "数据库连接失败"}
)
View Source
var LicenseClient *sdk.LicenseClient
View Source
var Logger *zap.Logger
View Source
var ProductLicense = &License{}

Functions

func DecodeErr

func DecodeErr(err error, data interface{}) (int, string, interface{})

func DoInstanceWork added in v1.2.3

func DoInstanceWork(client *sdk.LicenseClient)

func DoProductWork

func DoProductWork(client *sdk.LicenseClient)

func GetLicenseClient

func GetLicenseClient() (client *sdk.LicenseClient, err error)

创建grpc客户端

func GinLogger

func GinLogger() gin.HandlerFunc

GinLogger 接收gin框架默认的日志

func GinRecovery

func GinRecovery(stack bool) gin.HandlerFunc

GinRecovery recover掉项目可能出现的panic,并使用zap记录相关日志

func NewLogger

func NewLogger(config zapcore.EncoderConfig, logLevel string) *zap.Logger

func NewSugaredLogger

func NewSugaredLogger(config zapcore.EncoderConfig, logLevel string) *zap.SugaredLogger

Types

type BgPageRes

type BgPageRes struct {
	Code  int         `json:"code"`
	Msg   string      `json:"msg"`
	Data  interface{} `json:"data"`
	Total int64       `json:"total"`
}

func (BgPageRes) Error

func (b BgPageRes) Error() string

func (BgPageRes) ErrorDes

func (b BgPageRes) ErrorDes(errDes string) BgPageRes

func (BgPageRes) ErrorDetail

func (b BgPageRes) ErrorDetail(err error) BgPageRes

type BgRes

type BgRes struct {
	Code int         `json:"code"`
	Msg  string      `json:"msg"`
	Data interface{} `json:"data"`
}

func (BgRes) Error

func (b BgRes) Error() string

func (BgRes) ErrorDes

func (b BgRes) ErrorDes(errDes string) BgRes

func (BgRes) ErrorDetail

func (b BgRes) ErrorDetail(err error) BgRes

type HTTP added in v1.2.1

type HTTP interface {
	Load() Http
	NewServer() Http
}

type Http added in v1.2.1

type Http struct {
}

func (Http) Load added in v1.2.1

func (h Http) Load(base *gin.RouterGroup)

func (Http) NewServer added in v1.2.1

func (Http) NewServer() *http.Server

type License

type License struct {
	License       *license.License
	Code          int
	Msg           string
	Host          string
	InstanceCount int
	InstanceNum   int
}

Jump to

Keyboard shortcuts

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