base_response

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2025 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	SUCCESS        = NewRetCode(0, "Success")
	UnknownError   = NewRetCode(10000, "Unknown error")
	Unauthorized   = NewRetCode(10001, "Unauthorized")
	WrongParams    = NewRetCode(10002, "Wrong params")
	BindDataFailed = NewRetCode(10003, "Bind data failed")
	Forbidden      = NewRetCode(10004, "Forbidden")
)

Functions

This section is empty.

Types

type PageRequest

type PageRequest struct {
	PageSize    uint `form:"pageSize"`
	CurrentPage uint `form:"current"`
}

func (*PageRequest) Validate

func (w *PageRequest) Validate() (err error)

type PageResponse

type PageResponse struct {
	Code        int         `json:"code"`
	Message     string      `json:"message"`
	Error       string      `json:"error"`
	Data        interface{} `json:"data"`
	CurrentPage uint        `json:"current"`
	PageSize    uint        `json:"pageSize"`
	Total       uint64      `json:"total"`
}

func NewDataPageResponse

func NewDataPageResponse(data interface{}, currentPage, pageSize uint, total uint64) *PageResponse

func NewErrorPageResponse

func NewErrorPageResponse(err error, retCode *RetCode, currentPage, pageSize uint, total uint64) *PageResponse

func NewPageResponse

func NewPageResponse(currentPage, pageSize uint, total uint64) *PageResponse

type Response

type Response struct {
	Code    int         `json:"code"`
	Message string      `json:"message"`
	Error   string      `json:"error"`
	Data    interface{} `json:"data"`
}

func NewDataResponse

func NewDataResponse(data interface{}) *Response

func NewErrorResponse

func NewErrorResponse(err error, retcode *RetCode) *Response

func NewResponse

func NewResponse() *Response

type RetCode

type RetCode struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
}

func NewRetCode

func NewRetCode(code int, message string) *RetCode

Jump to

Keyboard shortcuts

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