query

package
v0.0.0-...-8ca34be Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2021 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildQueryFields

func BuildQueryFields(fields map[string]string) string

func BuildQueryFilter

func BuildQueryFilter(filters []FilterParameter, mapFields map[string]string) (query string, values []interface{}, qtd int)

func BuildQueryFilterPage

func BuildQueryFilterPage(filters []FilterParameter, pageable Pageable, mapFields map[string]string,
	sqlStatement string, sqlStatementCount string) ([]interface{}, []interface{}, string, string)

func BuildQueryPage

func BuildQueryPage(qtd int) (query string)

func BuildQuerySort

func BuildQuerySort(page Pageable) string

func BuildSelectQuery

func BuildSelectQuery(fields map[string]string, strQueryFrom string,
	strQueryPage string, strFilter string, page Pageable) (SQL, SQLCount)

func TotalPage

func TotalPage(pageSize int32, totalElements int64) int32

Types

type FilterParameter

type FilterParameter struct {
	Field    string
	Operator Operator
	Value    interface{}
}

type Operator

type Operator string
const (
	EQ   Operator = "="
	GT   Operator = ">"
	GTE  Operator = ">="
	LT   Operator = "<"
	LTE  Operator = "<="
	NE   Operator = "<>"
	LIKE Operator = " LIKE "
)

func (Operator) ToString

func (operator Operator) ToString() string

type Page

type Page interface {

	// total number of pages
	GetTotalPages() int32

	// total number of items
	GetTotalElements() int64

	// current page number
	GetPageNumber() int32

	// page size
	GetPageSize() int32

	// number of items on the current page
	GetNumberOfElements() int32

	// list of items on this page
	GetContent() interface{}
}

func BuildPage

func BuildPage(content interface{}, totalElements int64, totalPageElements int32, pageable Pageable) Page

type PageData

type PageData struct {
	TotalPage            int32
	TotalElements        int64
	PageNumber           int32
	PageSize             int32
	PageNumberOfElements int32
	Content              interface{}
}

func (PageData) GetContent

func (p PageData) GetContent() interface{}

func (PageData) GetNumberOfElements

func (p PageData) GetNumberOfElements() int32

func (PageData) GetPageNumber

func (p PageData) GetPageNumber() int32

func (PageData) GetPageSize

func (p PageData) GetPageSize() int32

func (PageData) GetTotalElements

func (p PageData) GetTotalElements() int64

func (PageData) GetTotalPage

func (p PageData) GetTotalPage(pageSize int32, totalElements int64) int32

func (PageData) GetTotalPages

func (p PageData) GetTotalPages() int32

type Pageable

type Pageable interface {

	/**
	 * Returns the page to be returned.
	 *
	 * @return the page to be returned.
	 */
	GetPageNumber() int32

	/**
	 * Returns the number of items to be returned.
	 *
	 * @return the number of items of that page
	 */
	GetPageSize() int32

	GetOffset() int32

	/**
	* Returns the sorting parameters.
	*
	* @return
	 */
	GetSort() map[string]string

	/**
	 * Returns the {@link Pageable} requesting the next {@link Page}.
	 *
	 * @return
	 */
	Next() Pageable

	/**
	 * Returns the previous {@link Pageable} or the first {@link Pageable} if the current one already is the first one.
	 *
	 * @return
	 */
	PreviousOrFirst() Pageable

	/**
	 * Returns the {@link Pageable} requesting the first page.
	 *
	 * @return
	 */
	First() Pageable

	/**
	 * Returns whether there's a previous {@link Pageable} we can access from the current one. Will return
	 * {@literal false} in case the current {@link Pageable} already refers to the first page.
	 *
	 * @return
	 */
	HasPrevious() bool
}

type PageableData

type PageableData struct {
	Page int32
	Size int32
	Sort map[string]string
}

func (PageableData) First

func (p PageableData) First() Pageable

func (PageableData) GetOffset

func (p PageableData) GetOffset() int32

func (PageableData) GetPageNumber

func (p PageableData) GetPageNumber() int32

func (PageableData) GetPageSize

func (p PageableData) GetPageSize() int32

func (PageableData) GetSort

func (p PageableData) GetSort() map[string]string

func (PageableData) HasPrevious

func (p PageableData) HasPrevious() bool

func (PageableData) Next

func (p PageableData) Next() Pageable

func (PageableData) PreviousOrFirst

func (p PageableData) PreviousOrFirst() Pageable

type Report

type Report struct {
	Info    map[string]interface{}
	Header  []string
	Records []map[string]interface{}
	Total   int64
}

func GetReport

func GetReport(DBX *sqlx.DB, SQL string) (Report, error)

type SQL

type SQL string

type SQLCount

type SQLCount string

Jump to

Keyboard shortcuts

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