response

package
v1.10.5 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2025 License: MulanPSL-2.0 Imports: 3 Imported by: 0

README

gylib, stdresp

统一定义返回值结构,以及相关常用方法

{
  "code": "RC00000",
  "info": "Success"
}

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CacheError = &ResponseCode{Code: "RC81001", Info: "缓存操作失败"}
View Source
var DB_ERROR = &ResponseCode{Code: "RC80000", Info: "DBError"}
View Source
var DB_NOT_FOUND = &ResponseCode{Code: "RC80404", Info: "DBError: record not found"}
View Source
var GENERAL_ERROR = &ResponseCode{Code: "RC60000", Info: "FAILURE"}
View Source
var MGMT_TOKEN_DISABLE_ERROR = &ResponseCode{Code: "RC50090", Info: "MgmtTokenDisabled"}
View Source
var MGMT_TOKEN_EXPIRE_ERROR = &ResponseCode{Code: "RC50099", Info: "MgmtTokenExpireOrInvalid: %s"}
View Source
var PARAM_ERROR = &ResponseCode{Code: "RC70000", Info: "ParamError"}
View Source
var SUCCESS = &ResponseCode{Code: "RC00000", Info: "SUCCESS"}
View Source
var SYS_ERROR = &ResponseCode{Code: "RC90000", Info: "SysError"}
View Source
var TOKEN_EXPIRE_ERROR = &ResponseCode{Code: "RC50000", Info: "TokenExpireOrInvalid"}

Functions

func ErrorHandler added in v1.0.1

func ErrorHandler(resp *ResponseCode, errMsg string, c *gin.Context, abort bool)

func GeneralDBHandler added in v1.0.1

func GeneralDBHandler(err error, c *gin.Context)

func GeneralErrorHandler added in v1.0.1

func GeneralErrorHandler(err error, c *gin.Context)

func GeneralErrorMessageHandler added in v1.0.1

func GeneralErrorMessageHandler(errMsg string, c *gin.Context)

func GeneralParamHandler added in v1.0.1

func GeneralParamHandler(err error, c *gin.Context)

func GeneralParamMessageHandler added in v1.0.1

func GeneralParamMessageHandler(errMsg string, c *gin.Context)

func GeneralResultHandler added in v1.0.1

func GeneralResultHandler(result interface{}, err error, c *gin.Context)

func GeneralSuccessHandler added in v1.0.1

func GeneralSuccessHandler(result interface{}, c *gin.Context)

func GeneralSuccessMessageHandler added in v1.0.1

func GeneralSuccessMessageHandler(message string, c *gin.Context)

func SystemErrorHandler added in v1.0.1

func SystemErrorHandler(err error, c *gin.Context)

Types

type PageInfo

type PageInfo struct {
	TotalPages int `json:"totalPages"`
	PageNo     int `json:"pageNo"`
	PageSize   int `json:"pageSize"`
}

type PageResult

type PageResult struct {
	PageInfo *PageInfo   `json:"pageInfo,omitempty"`
	Data     interface{} `json:"data,omitempty"`
}

type Response

type Response struct {
	Code   string      `json:"code"`
	Info   string      `json:"info"`
	Result interface{} `json:"result,omitempty"`
}

func (*Response) Init

func (re *Response) Init(code *ResponseCode, hint string, result interface{})

func (*Response) InitError

func (re *Response) InitError(code *ResponseCode, hint string)

func (*Response) InitFromResp

func (re *Response) InitFromResp(srcResp *Response)

func (*Response) InitPageSuccess

func (re *Response) InitPageSuccess(totalPages, pageNo, pageSize int, results interface{})

func (*Response) InitSuccess

func (re *Response) InitSuccess()

func (*Response) InitSuccessFull

func (re *Response) InitSuccessFull(hint string, result interface{})

func (*Response) InitSuccessHint

func (re *Response) InitSuccessHint(hint string)

func (*Response) InitSuccessResult

func (re *Response) InitSuccessResult(result interface{})

func (*Response) IsSuccess

func (re *Response) IsSuccess() bool

type ResponseCode

type ResponseCode struct {
	Code string
	Info string
}

Jump to

Keyboard shortcuts

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