response

package
v0.5.5 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2024 License: MulanPSL-2.0 Imports: 1 Imported by: 0

README

gylib, stdresp

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

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

Documentation

Index

Constants

This section is empty.

Variables

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

This section is empty.

Types

type PageInfo

type PageInfo struct {
	Total    int64 `json:"total"`
	PageNo   int   `json:"page_no"`
	PageSize int   `json:"page_size"`
}

type PageResult

type PageResult struct {
	PageInfo *PageInfo   `json:"page_info,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(total int64, 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