resp

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2023 License: MIT Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	SuccT        = &T{Code: SuccErrCode, Msg: ErrCodeMsg[SuccErrCode], Data: nil}
	FailT        = &T{Code: FailErrCode, Msg: ErrCodeMsg[FailErrCode], Data: nil}
	InternalErrT = &T{Code: InternalErrCode, Msg: ErrCodeMsg[InternalErrCode], Data: nil}
	ParamErrT    = &T{Code: ParamErrCode, Msg: ErrCodeMsg[ParamErrCode], Data: nil}
	AuthErrT     = &T{Code: AuthErrCode, Msg: ErrCodeMsg[AuthErrCode], Data: nil}
	PermErrT     = &T{Code: PermErrCode, Msg: ErrCodeMsg[PermErrCode], Data: nil}
	ExistErrT    = &T{Code: ExistErrCode, Msg: ErrCodeMsg[ExistErrCode], Data: nil}
	NotFoundErrT = &T{Code: NotFoundErrCode, Msg: ErrCodeMsg[NotFoundErrCode], Data: nil}
	LimitErrT    = &T{Code: LimitErrCode, Msg: ErrCodeMsg[LimitErrCode], Data: nil}
	TimeoutErrT  = &T{Code: TimeoutErrCode, Msg: ErrCodeMsg[TimeoutErrCode], Data: nil}
	OtherErrT    = &T{Code: OtherErrCode, Msg: ErrCodeMsg[OtherErrCode], Data: nil}
)
View Source
var ErrCodeMsg = map[RespCode]string{
	SuccErrCode:     "ok",
	FailErrCode:     "操作失败",
	InternalErrCode: "内部错误",
	ParamErrCode:    "参数错误",
	AuthErrCode:     "认证失败",
	PermErrCode:     "无权限",
	ExistErrCode:    "数据已存在",
	NotFoundErrCode: "数据未找到",
	LimitErrCode:    "已限制操作",
	TimeoutErrCode:  "超时错误",
	OtherErrCode:    "未知错误",
}

Functions

This section is empty.

Types

type Pt added in v0.0.9

type Pt *T

func AuthErr

func AuthErr() Pt

func ExistErr

func ExistErr() Pt

func Fail

func Fail() Pt

func InternalErr

func InternalErr() Pt

func LimitErr

func LimitErr() Pt

func NotFoundErr

func NotFoundErr() Pt

func OtherErr

func OtherErr() Pt

func ParamErr

func ParamErr() Pt

func PermErr

func PermErr() Pt

func Succ

func Succ(data interface{}) Pt

func TimeoutErr

func TimeoutErr() Pt

type RespCode

type RespCode int
const (
	SuccErrCode RespCode = iota
	FailErrCode          // 1

	InternalErrCode // 2
	ParamErrCode    // 3
	AuthErrCode     // 4
	PermErrCode     // 5
	ExistErrCode    // 6
	NotFoundErrCode // 7
	LimitErrCode    // 8
	TimeoutErrCode  // 9
	OtherErrCode    // 10
)

type T

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

func (T) GetCode

func (r T) GetCode() RespCode

func (T) GetData

func (r T) GetData() interface{}

func (T) GetMsg

func (r T) GetMsg() string

func (T) IsSucc

func (r T) IsSucc() bool

Jump to

Keyboard shortcuts

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