app

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2020 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Description: Author: Michael Cheung Github: https://github.com/gzmichaelcheung Date: 2020-11-23 15:00:22 LastEditors: Michael Cheung LastEditTime: 2020-11-23 15:00:24

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetPage

func GetPage(c *gin.Context) int

func GetPageOffset

func GetPageOffset(page, pageSize int) int

func GetPageSize

func GetPageSize(c *gin.Context) int

Types

type Pager

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

type Response

type Response struct {
	Ctx *gin.Context
}

func NewResponse

func NewResponse(ctx *gin.Context) *Response

func (*Response) ToErrorResponse

func (r *Response) ToErrorResponse(err *errcode.Error)

func (*Response) ToResponse

func (r *Response) ToResponse(data interface{})

func (*Response) ToResponseList

func (r *Response) ToResponseList(list interface{}, totalRows int)
{
	"list": {
		"xxx":"xxx",
		"yyy":"yyy"
	},{
		"zzz":"zzz"
	}
	"pager": {
		"page": 0,
		"page_size": 20,
		"total_rows": 1024
	}
}

type ValidError

type ValidError struct {
	Key     string
	Message string
}

func (*ValidError) Error

func (v *ValidError) Error() string

type ValidErrors

type ValidErrors []*ValidError

func BindAndValid

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

func (ValidErrors) Error

func (v ValidErrors) Error() string

func (ValidErrors) Errors

func (v ValidErrors) Errors() []string

Jump to

Keyboard shortcuts

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