formatter

package
v0.0.0-...-fe5219f Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2020 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ValidTypeInt     = "int"
	ValidTypeBool    = "bool"
	ValidTypeFloat   = "float"
	ValidTypeMap     = "map"
	ValidTypeString  = "string"
	ValidTypeStrings = "strings"
)
View Source
var (
	IntFormatter    intFormatter
	BoolFormatter   boolFormatter
	FloatFormatter  floatFormatter
	StringFormatter stringFormatter
)

Functions

func ApiError

func ApiError(bc *beegoContext.Context, errMsg string)

func CheckRule

func CheckRule(rule Rule) error

func GetParamRequireError

func GetParamRequireError(key string) error

Types

type APIDataResponse

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

接口返回的data部分数据

func NewAPIDataResponse

func NewAPIDataResponse() *APIDataResponse

func (*APIDataResponse) Init

func (a *APIDataResponse) Init() *APIDataResponse

func (*APIDataResponse) SetCode

func (a *APIDataResponse) SetCode(code int) *APIDataResponse

func (*APIDataResponse) SetData

func (a *APIDataResponse) SetData(data interface{}) *APIDataResponse

func (*APIDataResponse) SetMsg

func (a *APIDataResponse) SetMsg(msg string) *APIDataResponse

type APIResponse

type APIResponse struct {
	Ret  int              `json:"ret"`
	Msg  string           `json:"msg"`
	Data *APIDataResponse `json:"data"`
}

顶层接口返回

func NewAPIResponse

func NewAPIResponse() *APIResponse

创建一个返回实例

func (*APIResponse) Error

func (r *APIResponse) Error(ret int, msg string) *APIResponse

快捷接口,系统错误

func (*APIResponse) Fail

func (r *APIResponse) Fail(code int, msg string) *APIResponse

快捷接口,业务失败

func (*APIResponse) SetData

func (r *APIResponse) SetData(data *APIDataResponse) *APIResponse

设置返回的具体业务数据

func (*APIResponse) SetMsg

func (r *APIResponse) SetMsg(msg string) *APIResponse

设置(错误)提示信息 msg

func (*APIResponse) SetRet

func (r *APIResponse) SetRet(ret int) *APIResponse

设置ret状态码

func (*APIResponse) Success

func (r *APIResponse) Success(data interface{}) *APIResponse

快捷接口,业务成功返回

type Formatter

type Formatter interface {
	FormatterType() string
	Parse(bc *beegoContext.Context, rule Rule) interface{}
}

type Rule

type Rule map[string]interface{}

Jump to

Keyboard shortcuts

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