response

package
v1.8.7 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2025 License: Apache-2.0 Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Page

type Page struct {
	Total int64 `json:"total"` // 总数量 / Total number of items
	Items any   `json:"items"` // 当前页的数据集合 / Data set of the current page
}

Page 结构体用于分页返回数据 Page struct defines the pagination response data

func PageResponse added in v1.8.7

func PageResponse(total int64, items any) *Page

PageResponse 函数用于分页数据返回 PageResponse function is used for paginated data response

type Write

type Write struct {
	Status  int    `json:"status"`          // 0: 成功, 1: 失败 / 0: Success, 1: Failure
	Code    string `json:"code"`            // 业务状态码 / Business status code
	Message string `json:"message"`         // 用户友好提示信息 / User-friendly message
	Data    any    `json:"data"`            // 实际数据 / Actual data
	Error   any    `json:"error,omitempty"` // 错误信息 / Error message
}

Write 结构体用于定义API的返回参数 Write struct defines the response parameters for API

func Fail

func Fail(code, msg string, err ...string) *Write

Fail 函数用于错误返回 Fail function is used for error response

func Success

func Success(code, msg string, data ...any) *Write

Success 函数用于成功返回 Success function is used for successful response

Jump to

Keyboard shortcuts

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