Documentation ¶
Index ¶
- Variables
- type ErrorCode
- type JsonResult
- func (jr *JsonResult) No(err ErrorCode) *JsonResult
- func (jr *JsonResult) SetCode(code int) *JsonResult
- func (jr *JsonResult) SetData(data interface{}) *JsonResult
- func (jr *JsonResult) SetMsg(Msg string) *JsonResult
- func (jr *JsonResult) SetSuccess(success bool) *JsonResult
- func (jr *JsonResult) Yes(data interface{}) *JsonResult
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 ¶
func NewAssertError ¶
func NewAuthError ¶
func NewForbiddenError ¶
func NewInternalError ¶
func NewNotFoundError ¶
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) 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
Click to show internal directories.
Click to hide internal directories.