response

package
v0.0.1-202403281358 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Custum

func Custum(c IRespWriter, data gin.H)

Custum 兼容函数

func Error

func Error(c IRespWriter, code int, err error, msg string)

Error 失败数据处理

func GenerateMsgIDFromContext

func GenerateMsgIDFromContext(c IRespWriter) string

GenerateMsgIDFromContext 生成msgID

func OK

func OK(c IRespWriter, data interface{}, msg string)

OK 通常成功数据处理

func PageOK

func PageOK(c IRespWriter, result interface{}, count int, pageIndex int, pageSize int, msg string)

PageOK 分页数据处理

Types

type DebugInfo

type DebugInfo struct {
	Err   error  `swaggertype:"string"` // 错误信息
	Stack string `swaggertype:"string"` // 错误堆栈
}

type IRespWriter

type IRespWriter interface {
	GetHeader(key string) string
	SetHeader(key string, val string)
	Set(key string, val any)
	Get(key string) (val any, exists bool)
	AbortWithStatusJSON(code int, obj any)
}

type PageData

type PageData struct {
	Total    int         `json:"total"`    // 总数
	PageNum  int         `json:"pageNum"`  // 当前页
	PageSize int         `json:"pageSize"` // 当前每页条数
	List     interface{} `json:"list"`     // 数据列表
}

type Response

type Response struct {
	RequestId string      `json:"requestId,omitempty"` // 链路id
	Code      int         `json:"code,omitempty"`      // 状态码
	Msg       string      `json:"msg,omitempty"`       // 提示消息(可展示)
	Status    string      `json:"status,omitempty"`
	Data      interface{} `json:"data,omitempty"`  // 数据内容
	Debug     *DebugInfo  `json:"debug,omitempty"` // 调试模式下异常信息
}

func (*Response) SetCode

func (r *Response) SetCode(code int) Responses

func (*Response) SetData

func (r *Response) SetData(data interface{}) Responses

func (*Response) SetError

func (r *Response) SetError(err error) Responses

func (*Response) SetMsg

func (r *Response) SetMsg(msg string) Responses

func (*Response) SetSuccess

func (r *Response) SetSuccess(success bool) Responses

func (*Response) SetTraceID

func (r *Response) SetTraceID(requestId string) Responses

type Responses

type Responses interface {
	SetCode(int) Responses
	SetTraceID(string) Responses
	SetMsg(string) Responses
	SetData(interface{}) Responses
	SetSuccess(bool) Responses
	SetError(err error) Responses
}

func NewResponse

func NewResponse() Responses

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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