common

package
v0.0.0-...-d28bcca Latest Latest
Warning

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

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

Documentation

Overview

Package common travel 公共包 包括全局函数,版本号,常量, 接口 ,错误error

Index

Constants

View Source
const (
	WarnCode                  = 3000
	SuccessCode               = 0
	ErrorCode                 = 5000
	DevelopCode               = 3111
	UnLoginCode               = 4001
	CreateFailCode            = 1001
	PermissionCode            = 4003
	LimitCode                 = 4100
	EmptyParamCode            = 1002
	InvalidParametersCode     = 4101
	ServiceFailed             = 4041
	ParamVerifyFailed         = 4020
	Error                     = "error"
	Success                   = "success"
	UnLoginError              = "please login!"
	NotFoundError             = "not found!"
	PermissionError           = "Permission denied!"
	LimitError                = "access api too frequently!"
	InvalidParametersError    = "invalid parameters"
	CreateFail                = "create record fail!"
	NotFound                  = 4004
	RecordNotFound            = 4040
	AccessForbid              = 4003
	InvalidTokenCode          = 4100
	InvalidTokenError         = "invalid token"
	VerifyNotMatch            = 1003
	PasswordOrAccountNotMatch = "password or account not match"
	UserAccountForbid         = "user account forbid"
	RegisterFail              = 1004
	RegisterFailTip           = "register failed!"
	AppTokenCookie            = "authorization"
	DevelopCodeError          = "developing"
	ServiceFailedError        = "server failed!"
	ParamVerifyFailedError    = "param verify error!"
	RecordNotFoundError       = "empty"
	Page                      = 1  // 默认页
	Count                     = 20 // 默认分页量
)

Variables

This section is empty.

Functions

func BasePath

func BasePath() string

func Echo

func Echo(v interface{})

func SmsDebugOff

func SmsDebugOff()

func SmsDebugOn

func SmsDebugOn()

func StoragePath

func StoragePath() string

Types

type BaseRequestContext

type BaseRequestContext interface {
	Method() string
	IsJsonStream() bool
	GetActionId() string
	GetJsonData() beego.M
	GetContentType() string
	GetJson() (beego.M, error)
	GetSession() session.Store
	GetParent() *beego.Controller
	GetInput() *context.BeegoInput
	JsonDecode(v interface{}) error
	GetInt(key string, def ...int) int
	GetControllerAction() *RouterAction
	GetBool(key string, def ...bool) bool
	GetString(key string, def ...string) string
	GetStrings(key string, def ...[]string) []string
	Session(key string, v ...interface{}) interface{}
	GetHeader() http.Header
	SetHeader(string, string)
	Cookie(string, ...interface{}) interface{}
	GetParam(key string, defaults ...interface{}) (interface{}, bool)
}

type ErrorImpl

type ErrorImpl struct {
	ErrCode int    `json:"errno"`
	ErrMsg  string `json:"errmsg"`
	// contains filtered or unexported fields
}

func (*ErrorImpl) Code

func (this *ErrorImpl) Code() int

func (*ErrorImpl) Error

func (this *ErrorImpl) Error() string

func (*ErrorImpl) Map

func (this *ErrorImpl) Map() map[string]interface{}

func (*ErrorImpl) Msg

func (this *ErrorImpl) Msg() string

func (*ErrorImpl) Parent

func (this *ErrorImpl) Parent() Errors

func (*ErrorImpl) Set

func (this *ErrorImpl) Set(key string, v interface{}) Errors

func (*ErrorImpl) String

func (this *ErrorImpl) String() string

type Errors

type Errors interface {
	Code() int
	Msg() string
	Parent() Errors
	Set(key string, v interface{}) Errors
	Map() map[string]interface{}
	error
}

func ErrorWrap

func ErrorWrap(err Errors, args ...interface{}) Errors

ErrorWrap err Errors ErrCode string ErrMsg int

func NewErrors

func NewErrors(args ...interface{}) Errors

NewErrors ErrCode string ErrMsg int

type GetEntry

type GetEntry interface {
	Get(key string) (interface{}, bool)
}

type GetterEntry

type GetterEntry interface {
	Get(key string, defaults ...interface{}) interface{}
}

type ResponseImpl

type ResponseImpl struct {
	Code    int         `json:"code"`
	Message string      `json:"msg"`
	Error   Errors      `json:"error"`
	Data    interface{} `json:"data"`
}

func (*ResponseImpl) Empty

func (this *ResponseImpl) Empty() bool

func (*ResponseImpl) Get

func (this *ResponseImpl) Get(key string, defaults ...interface{}) interface{}

func (*ResponseImpl) GetCode

func (this *ResponseImpl) GetCode() int

func (*ResponseImpl) GetData

func (this *ResponseImpl) GetData() interface{}

func (*ResponseImpl) GetDataByKey

func (this *ResponseImpl) GetDataByKey(key string, defaults ...interface{}) interface{}

func (*ResponseImpl) GetError

func (this *ResponseImpl) GetError() Errors

func (*ResponseImpl) GetMsg

func (this *ResponseImpl) GetMsg() string

func (*ResponseImpl) Has

func (this *ResponseImpl) Has(key string) bool

func (*ResponseImpl) IsSuccess

func (this *ResponseImpl) IsSuccess() bool

func (*ResponseImpl) Json

func (this *ResponseImpl) Json() ([]byte, error)

func (*ResponseImpl) Set

func (this *ResponseImpl) Set(key string, v interface{}) ResponseJson

func (*ResponseImpl) SetDataByKey

func (this *ResponseImpl) SetDataByKey(key string, v interface{}) ResponseJson

func (*ResponseImpl) String

func (this *ResponseImpl) String() string

func (*ResponseImpl) UnJson

func (this *ResponseImpl) UnJson(bytes []byte) error

type ResponseJson

type ResponseJson interface {
	fmt.Stringer
	GetCode() int
	GetMsg() string
	GetError() Errors
	GetData() interface{}
	UnJson(bytes []byte) error
	Json() ([]byte, error)
	Set(key string, v interface{}) ResponseJson
	Has(key string) bool
	Empty() bool
	IsSuccess() bool
	Get(key string, defaults ...interface{}) interface{}
	GetDataByKey(key string, defaults ...interface{}) interface{}
}

func NewAccessLimitResp

func NewAccessLimitResp(data ...interface{}) ResponseJson

NewAccessLimitResp 访问控制 data interface msg string code int

func NewErrorResp

func NewErrorResp(err Errors, args ...interface{}) ResponseJson

NewErrorResp 请求参数异常 err Errors msg string code int data interface{}

func NewFailedResp

func NewFailedResp(code int, args ...interface{}) ResponseJson

NewFailedResp 构造成功响应体 data interface msg string code int

func NewInDevResp

func NewInDevResp(api string, args ...interface{}) ResponseJson

NewInDevResp 开发中.... err Errors msg string code int data interface{}

func NewInvalidParametersResp

func NewInvalidParametersResp(data ...interface{}) ResponseJson

NewInvalidParametersResp 请求参数异常 data interface msg string code int

func NewNotFoundResp

func NewNotFoundResp(args ...interface{}) ResponseJson

NewNotFoundResp 未找到 对应记录 err Errors msg string code int data interface{}

func NewPermissionResp

func NewPermissionResp(args ...interface{}) ResponseJson

NewPermissionResp 权限异常 err Errors msg string code int data interface{}

func NewResponse

func NewResponse(args ...interface{}) ResponseJson

func NewSuccessResp

func NewSuccessResp(data interface{}, args ...interface{}) ResponseJson

NewSuccessResp 构造成功响应体 data interface msg string code int

func NewUnLoginResp

func NewUnLoginResp(data ...interface{}) ResponseJson

NewUnLoginResp 未登陆响应 data interface msg string code int

func NewVerifyErrorResp

func NewVerifyErrorResp(args ...interface{}) ResponseJson

NewVerifyErrorResp 参数验证失败 err Errors msg string code int data interface{}

type RouterAction

type RouterAction struct {
	Controller string
	Action     string
}

type SetEntry

type SetEntry interface {
	Set(key string, v interface{}) bool
}

type SetterEntry

type SetterEntry interface {
	Set(key string, v interface{})
}

type Version

type Version string // 版本号

Version 版本号协议 :https://semver.org/lang/zh-CN/

X.Y.Z

主版本号、次版本号及修订号以数值比较,例如:1.0.0 < 2.0.0 < 2.1.0 < 2.1.1 范例:1.0.0-alpha < 1.0.0-alpha.1 < 1.0.0-alpha.beta < 1.0.0-beta < 1.0.0-beta.2 < 1.0.0-beta.11 < 1.0.0-rc.1 < 1.0.0。 <major> "." <minor> "." <patch>

func (Version) Check

func (this Version) Check(ver string, compare string) bool

func (Version) IsVersion

func (this Version) IsVersion() bool

Jump to

Keyboard shortcuts

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