response

package
v0.0.64 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ResponesFILE

func ResponesFILE(c *gin.Context, filename string)

func ResponseBytes

func ResponseBytes(c *gin.Context, code Code, data ...[]byte)

func ResponseBytesList

func ResponseBytesList(c *gin.Context, code Code, total uint64, data ...[]byte)

func ResponseDATA

func ResponseDATA(c *gin.Context, data []byte, headers ...map[string]string)

func ResponseJSON

func ResponseJSON(c *gin.Context, code Code, data ...any)

func ResponseTEXT

func ResponseTEXT(c *gin.Context, code Code, data ...any)

Types

type Code

type Code int32
const (
	// 成功处理和失败处理状态码
	CodeSuccess Code = 0
	CodeFailure Code = -1

	// 通用状态码
	CodeInvalidParam Code = 1000 + iota
	CodeBadRequest
	CodeInvalidToken
	CodeNeedLogin
	CodeUnauthorized
	CodeNetworkTimeout
	CodeContextTimeout
	CodeTooManyRequests
	CodeNotFound
	CodeForbidden
	CodeAlreadyExist
)
const (
	// 业务状态码
	CodeServerCallbackTimeout Code = 2000 + iota
	CodeInvalidLogin
	CodeInvalidSignup
	CodeOldPasswordNotMatch
	CodeNewPasswordNotMatch

	CodeRequireRoleId

	CodeNotFoundQueryID
	CodeNotFoundRouteID
	CodeNotFoundRoleId
	CodeNotFoundUser
	CodeNotFoundUserId
	CodeNotFoundRoomType
	CodeNotFoundCategory

	CodeAlreadyExistsUser
	CodeAlreadyExistsRole
	CodeAlreadyExistsRoomType
	CodeAlreadyExistsCategory

	CodeTooLargeFile
	CodeNotPNGJPG

	CodeInvalidSoftwareLabel
)

func (Code) Msg

func (r Code) Msg() string

func (Code) Status

func (r Code) Status() int

func (Code) String

func (r Code) String() string

Jump to

Keyboard shortcuts

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