result

package
v0.7.5 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2023 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	SUCCESS              = ErrorCode{20000, "ok"}      // 运行成功
	PARAMS_ERROR         = ErrorCode{40000, "请求参数错误"}  // 参数错误
	DUPLICATE_USERNAME   = ErrorCode{40001, "用户名已存在"}  // 参数错误
	NOT_LOGIN_ERROR      = ErrorCode{40100, "未登录"}     // 账号未登录
	NO_AUTH_ERROR        = ErrorCode{40101, "账号无权限"}   // 账号无权限
	TOKEN_EXPIRE         = ErrorCode{40102, "登录信息过期"}  // 登录过期
	TOKEN_REMOTING_LOGIN = ErrorCode{40103, "账号异地登录"}  // 异地登录
	NOT_FOUND_ERROR      = ErrorCode{40400, "请求数据不存在"} // 数据不存在
	FORBIDDEN_ERROR      = ErrorCode{40300, "禁止访问"}    // 数据禁止访问
	LIMIT_ERROR          = ErrorCode{40301, "限制访问"}    // 数据禁止访问
	SYSTEM_ERROR         = ErrorCode{50000, "操作失败"}    // 系统内部出错
)

Functions

This section is empty.

Types

type ErrorCode

type ErrorCode struct {
	Code int    `json:"code"`
	Msg  string `json:"msg"`
}

func NewAssertError

func NewAssertError(msg any) ErrorCode

func NewAuthError

func NewAuthError(msg any) ErrorCode

func NewForbiddenError

func NewForbiddenError(msg any) ErrorCode

func NewInternalError

func NewInternalError(msg any) ErrorCode

func NewNotFoundError

func NewNotFoundError(msg any) ErrorCode

func (ErrorCode) Error

func (e ErrorCode) Error() string

func (ErrorCode) SetMsg

func (e ErrorCode) SetMsg(msg any) ErrorCode

type JsonResult

type JsonResult struct {
	// code
	Code int `json:"code" default:"0"`
	// response information
	Msg string `json:"msg" default:""`
	// data
	Data interface{} `json:"data,omitempty" default:"nil"` // 默认无数据时不显示该字段
	// whether success
	Success bool `json:"success" default:"false"`
}

func NewJsonResult

func NewJsonResult() *JsonResult

func (*JsonResult) No

func (jr *JsonResult) No(err ErrorCode) *JsonResult

No is run failed

func (*JsonResult) SetCode

func (jr *JsonResult) SetCode(code int) *JsonResult

func (*JsonResult) SetData

func (jr *JsonResult) SetData(data interface{}) *JsonResult

func (*JsonResult) SetMsg

func (jr *JsonResult) SetMsg(Msg string) *JsonResult

func (*JsonResult) SetSuccess

func (jr *JsonResult) SetSuccess(success bool) *JsonResult

func (*JsonResult) Yes

func (jr *JsonResult) Yes(data interface{}) *JsonResult

Yes is run successful

Jump to

Keyboard shortcuts

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