utils

package
v0.0.0-...-52d9df3 Latest Latest
Warning

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

Go to latest
Published: May 13, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Contains

func Contains[T any](arr []T, x T) bool

func ContainsFunc

func ContainsFunc[T any](arr []T, predicate func(T) bool) bool

Types

type FilterModel

type FilterModel struct {
	Field      string `query:"field"      json:"field"`
	Value      string `query:"value"      json:"value"`
	Comparison string `query:"comparison" json:"comparison"`
}

type ListQuery

type ListQuery struct {
	Size    int            `query:"size"    json:"size,omitempty"`
	Page    int            `query:"page"    json:"page,omitempty"`
	OrderBy string         `query:"orderBy" json:"orderBy,omitempty"`
	Filters []*FilterModel `query:"filters" json:"filters,omitempty"`
}

func GetListQueryFromCtx

func GetListQueryFromCtx(c echo.Context) (*ListQuery, error)

func NewListQuery

func NewListQuery(size int, page int) *ListQuery

func NewListQueryFromQueryParams

func NewListQueryFromQueryParams(size string, page string) *ListQuery

func (*ListQuery) GetLimit

func (q *ListQuery) GetLimit() int

GetLimit Get limit

func (*ListQuery) GetOffset

func (q *ListQuery) GetOffset() int

GetOffset Get offset

func (*ListQuery) GetOrderBy

func (q *ListQuery) GetOrderBy() string

GetOrderBy Get OrderBy

func (*ListQuery) GetPage

func (q *ListQuery) GetPage() int

GetPage Get OrderBy

func (*ListQuery) GetQueryString

func (q *ListQuery) GetQueryString() string

GetQueryString get query string

func (*ListQuery) GetSize

func (q *ListQuery) GetSize() int

GetSize Get OrderBy

func (*ListQuery) SetOrderBy

func (q *ListQuery) SetOrderBy(orderByQuery string)

SetOrderBy Set order by

func (*ListQuery) SetPage

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

SetPage Set page number

func (*ListQuery) SetSize

func (q *ListQuery) SetSize(sizeQuery string) error

SetSize Set page size

type ListResult

type ListResult[T any] struct {
	Size       int   `json:"size,omitempty"       bson:"size"`
	Page       int   `json:"page,omitempty"       bson:"page"`
	TotalItems int64 `json:"totalItems,omitempty" bson:"totalItems"`
	TotalPage  int   `json:"totalPage,omitempty"  bson:"totalPage"`
	Items      []T   `json:"items,omitempty"      bson:"items"`
}

func ListResultToListResultDto

func ListResultToListResultDto[TDto any, TModel any](
	listResult *ListResult[TModel],
) (*ListResult[TDto], error)

func NewListResult

func NewListResult[T any](items []T, size int, page int, totalItems int64) *ListResult[T]

func (*ListResult[T]) String

func (p *ListResult[T]) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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