utils

package
v0.0.0-...-3bf3187 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DEFAULT_SIZE int = 10
	MAX_SIZE     int = 50
)

Variables

This section is empty.

Functions

func AnyToBytesBuffer

func AnyToBytesBuffer(i interface{}) (*bytes.Buffer, error)

func GetHasMore

func GetHasMore(currentPage int, totalCount int, pageLimit int) bool

GetHasMore returns whether there is a next page

func GetTotalPages

func GetTotalPages(totalCount int, pageLimit int) int

GetTotalPages calculates the total number of pages using totalCount and pageLimit

func StringToInt64

func StringToInt64(num string) (int64, error)

func ValidateStruct

func ValidateStruct(ctx context.Context, s interface{}) error

Validate struct fields

Types

type Query

type Query struct {
	Limit  int    `json:"limit,omitempty"`
	Page   int    `json:"page,omitempty"`
	Search string `json:"search,omitempty"`
	Sort   string `json:"sort,omitempty"`
}

func GetPaginationFromCtx

func GetPaginationFromCtx(c echo.Context) (*Query, error)

GetPaginationFromCtx returns the query from the context

func (*Query) GetLimit

func (q *Query) GetLimit() int

GetLimit

func (*Query) GetOffset

func (q *Query) GetOffset() int

GetOffset

func (*Query) GetPage

func (q *Query) GetPage() int

GetPage

func (*Query) GetQueryString

func (q *Query) GetQueryString() string

func (*Query) GetSort

func (q *Query) GetSort() string

GetSort

func (*Query) SetLimit

func (q *Query) SetLimit(sizeQuery string) error

SetLimit

func (*Query) SetPage

func (q *Query) SetPage(pageQuery string) error

SetPage

func (*Query) SetSort

func (q *Query) SetSort(sortQuery string)

SetSort

Jump to

Keyboard shortcuts

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