businessCodex

package
v1.0.0-alpha Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2023 License: Apache-2.0 Imports: 0 Imported by: 0

README

错误码规则

  • 错误码需在 businessCode 包中进行定义。

Documentation

Index

Constants

View Source
const (
	// ZhCN 简体中文 - 中国
	ZhCN = "zh-cn"

	// EnUS 英文 - 美国
	EnUS = "en-us"
)

Variables

This section is empty.

Functions

func GetEnUSText

func GetEnUSText() map[int]string

func GetMySQLExecErrorCode

func GetMySQLExecErrorCode() (code int)

func GetParamBindErrorCode

func GetParamBindErrorCode() (code int)

func GetReturn401Map

func GetReturn401Map() map[int]struct{}

func GetServerErrorCode

func GetServerErrorCode() (code int)

func GetSucceedCode

func GetSucceedCode() (code int)

func GetTooManyRequestsCode

func GetTooManyRequestsCode() (code int)

func GetZhCNText

func GetZhCNText() map[int]string

func Init

func Init(enUS bool)

func SetEnUSText

func SetEnUSText(textMap map[int]string)

func SetLang

func SetLang(l string)

func SetMySQLExecErrorCode

func SetMySQLExecErrorCode(code int)

func SetParamBindErrorCode

func SetParamBindErrorCode(code int)

func SetReturn401Map

func SetReturn401Map(intMap map[int]struct{})

func SetServerErrorCode

func SetServerErrorCode(code int)

func SetSucceedCode

func SetSucceedCode(code int)

func SetTooManyRequestsCode

func SetTooManyRequestsCode(code int)

func SetZhCNText

func SetZhCNText(textMap map[int]string)

func Text

func Text(code int) string

Types

type Failure

type Failure Response

Failure 错误时返回结构 (保留type, 增加兼容性).

type Response

type Response struct {
	Code int         `json:"code"` // 业务码
	Msg  string      `json:"msg"`  // 描述信息
	Data interface{} `json:"data"` // 返回值
}

Response 统一返回结构. 错误时返回code和msg, 正确时返回data.

Jump to

Keyboard shortcuts

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