Documentation ¶
Overview ¶
Package domain implements domain utility functions.
Usage
p := domain.NewPageable(1, 10) fmt.Println(p.PageNo())
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SiftsToMap ¶
SiftsToMap returns the map from []Sift.
func SiftsToParams ¶
SiftsToParams returns the params(map) from []Sift.
Types ¶
type Page ¶
type Page interface { Pageable Pagination // Returns the previous Pageable or the first Pageable // if the current one already is the first one. // @return Previous() Pageable // Returns the Pageable requesting the next Page. // @return Next() Pageable // Returns the Pageable requesting the first page. // @return First() Pageable // Returns the Pageable requesting the last page. // @return Last() Pageable // Returns whether there's a previous Pageable we can access from // the current one. Will return false in case the current // Pageable already refers to the first page. // @return HasPrevious() bool // Returns whether there's a next Pageable we can access from // the current one. Will return false in case the current // Pageable already refers to the last page. // @return HasNext() bool // Returns whether the current Pageable is the first one. //@return IsFirst() bool // Returns whether the current Pageable is the last one. // @return IsLast() bool // Returns the number of total pages. // @return the number of total pages TotalPages() int // Returns the total amount of elements. // @return the total amount of elements TotalElements() int // Returns the page content as entity.Interfaces. // @return Content() entity.Interfaces // Returns the page content as slice. // @return Slice() interface{} // Set total amount of elements. SetTotalElements(totalElements int) // Set pageable information. SetPageable(pageable Pageable) // Set pagination information. SetPagination(pagination Pagination) }
Page a page is a sublist of a list of objects. It allows gain information about the position of it in the containing entire list.
func NewPage ¶
func NewPage(pageable Pageable, content entity.Interfaces, totalElements int) Page
NewPage returns the Page from pageable, content, totalElements.
func NewPageDefault ¶
func NewPageDefault(content entity.Interfaces) Page
NewPageDefault returns the default Page.
type Pageable ¶
type Pageable interface { // Returns the page to be returned. // @return the page to be returned. PageNo() int // Returns the number of items to be returned. // @return the number of items of that page PageSize() int // Returns the offset to be taken according to the underlying page and page size. // @return the offset to be taken Offset() int }
Pageable abstract interface for pagination information.
func NewPageable ¶
NewPageable returns the Pageable from pageNo, pageSize.
func NewPageableHTTP ¶
NewPageableHTTP returns the Pageable from HTTP.
func NewPageablePageNo ¶
NewPageablePageNo returns the Pageable from pageNo. PageSize defaults to 10
type Pagination ¶
Pagination abstract interface for pagination information.
func NewPagination ¶
func NewPagination(length, slider int, pageFn string) Pagination
NewPagination returns the Pagination from length, slider, function.
func NewPaginationDefault ¶
func NewPaginationDefault() Pagination
NewPaginationDefault returns the default Pagination. length defaults to 8 slider defaults to 1 function defaults to page
func NewPaginationLength ¶
func NewPaginationLength(length int) Pagination
NewPaginationLength returns the Pagination from length. slider defaults to 1 function defaults to page
type Sift ¶
type Sift interface { // Returns the name. // eg: sNameEQST // @return Name() string // Returns the name of query conditional filtering. // eg: Name // @return Key() string // Returns the value of query conditional filtering. // eg: goyy // @return Value() string // Returns the operator of query conditional filtering. // eg: EQ // @return Operator() string // Returns the type of query conditional filtering. // eg: ST // @return Type() string }
Sift query conditional filtering. eg: sNameEQST=goyy
func NewSift ¶
NewSift returns the Sift from name, value. Prefix[s] + Name + Operator[EQ|NE|...|OD] + Type[ST|BL|...|TS] example: sName sNameEQ sNameEQST sNameSTEQ sAgeGT sMemoLI
func NewSiftDeletion ¶
NewSiftDeletion returns the Sift: deletion = 0.