app

package
v0.0.0-...-dcbaf51 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2023 License: MulanPSL-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package app 服务应用相关包

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetPage

func GetPage(c *gin.Context) uint32

GetPage 获取页数

func GetPageOffset

func GetPageOffset(page, pageSize int) int

GetPageOffset 获取offset

func GetPageSize

func GetPageSize(c *gin.Context) uint32

GetPageSize 获取每页大小

func WriteResponse

func WriteResponse(c *gin.Context, err error, data Responser)

WriteResponse 写入返回结果

Types

type Pager

type Pager struct {
	Page      uint32 `json:"page"`
	PageSize  uint32 `json:"page_size"`
	TotalRows uint32 `json:"total_rows"`
}

Pager 分页结构体

type Response

type Response struct {
	Code int    `json:"status_code"`
	Msg  string `json:"status_msg"`
}

Response 响应结构体

func (*Response) SetCode

func (r *Response) SetCode(code int)

func (*Response) SetMsg

func (r *Response) SetMsg(msg string)

type Responser

type Responser interface {
	SetCode(int)
	SetMsg(string)
}

type ValidError

type ValidError struct {
	Key     string `json:"key"`
	Message string `json:"message"`
}

ValidError 参数验证失败结构体

func (*ValidError) Error

func (v *ValidError) Error() string

Error 返回参数验证错误信息

type ValidErrors

type ValidErrors []*ValidError

ValidErrors 将ValidErrors定义为[]*ValidError数组

func BindAndValid

func BindAndValid(c *gin.Context, v interface{}) (bool, ValidErrors)

BindAndValid 绑定并验证参数是否正确

func (ValidErrors) Error

func (v ValidErrors) Error() string

Error 返回所有参数验证错误信息

func (ValidErrors) Errors

func (v ValidErrors) Errors() []string

Errors 返回参数验证错误信息数组

Jump to

Keyboard shortcuts

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