response

package
v1.6.1 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Default = &response{}

Functions

func Custom added in v1.3.30

func Custom(c *gin.Context, data gin.H)

Custom 兼容函数

func Error

func Error(c *gin.Context, code int, err error, message ...string)

Error 失败数据处理

func OK

func OK(c *gin.Context, data interface{}, message ...string)

OK 通常成功数据处理

func PageOK

func PageOK(c *gin.Context, result interface{}, count int, pageIndex int, pageSize int, message ...string)

PageOK 分页数据处理

Types

type Page

type Page struct {
	Count     int `json:"count"`
	PageIndex int `json:"page"`
	PageSize  int `json:"size"`
}

type Response

type Response struct {
	// 数据集
	RequestId string `protobuf:"bytes,1,opt,name=requestId,proto3" json:"request_id,omitempty"`
	Code      int32  `protobuf:"varint,2,opt,name=code,proto3" json:"code"`
	Message   string `protobuf:"bytes,3,opt,name=msg,proto3" json:"message,omitempty"`
	Status    string `protobuf:"bytes,4,opt,name=status,proto3" json:"status,omitempty"`

	// 兼容性字段
	ErrCode int32 `protobuf:"varint,2,opt,name=errCode,proto3" json:"err_code"`
}

type Responses

type Responses interface {
	SetCode(int32)
	SetTraceID(string)
	SetMessage(string)
	SetData(interface{})
	SetSuccess(bool)
	Clone() Responses
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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