Documentation ¶
Overview ¶
Package common travel 公共包 包括全局函数,版本号,常量, 接口 ,错误error
Index ¶
- Constants
- func BasePath() string
- func Echo(v interface{})
- func SmsDebugOff()
- func SmsDebugOn()
- func StoragePath() string
- type BaseRequestContext
- type ErrorImpl
- type Errors
- type GetEntry
- type GetterEntry
- type ResponseImpl
- func (this *ResponseImpl) Empty() bool
- func (this *ResponseImpl) Get(key string, defaults ...interface{}) interface{}
- func (this *ResponseImpl) GetCode() int
- func (this *ResponseImpl) GetData() interface{}
- func (this *ResponseImpl) GetDataByKey(key string, defaults ...interface{}) interface{}
- func (this *ResponseImpl) GetError() Errors
- func (this *ResponseImpl) GetMsg() string
- func (this *ResponseImpl) Has(key string) bool
- func (this *ResponseImpl) IsSuccess() bool
- func (this *ResponseImpl) Json() ([]byte, error)
- func (this *ResponseImpl) Set(key string, v interface{}) ResponseJson
- func (this *ResponseImpl) SetDataByKey(key string, v interface{}) ResponseJson
- func (this *ResponseImpl) String() string
- func (this *ResponseImpl) UnJson(bytes []byte) error
- type ResponseJson
- func NewAccessLimitResp(data ...interface{}) ResponseJson
- func NewErrorResp(err Errors, args ...interface{}) ResponseJson
- func NewFailedResp(code int, args ...interface{}) ResponseJson
- func NewInDevResp(api string, args ...interface{}) ResponseJson
- func NewInvalidParametersResp(data ...interface{}) ResponseJson
- func NewNotFoundResp(args ...interface{}) ResponseJson
- func NewPermissionResp(args ...interface{}) ResponseJson
- func NewResponse(args ...interface{}) ResponseJson
- func NewSuccessResp(data interface{}, args ...interface{}) ResponseJson
- func NewUnLoginResp(data ...interface{}) ResponseJson
- func NewVerifyErrorResp(args ...interface{}) ResponseJson
- type RouterAction
- type SetEntry
- type SetterEntry
- type Version
Constants ¶
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 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 Errors ¶
type Errors interface { Code() int Msg() string Parent() Errors Set(key string, v interface{}) Errors Map() map[string]interface{} error }
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 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>