forked from ebhomengo/niki
30 lines
730 B
Go
30 lines
730 B
Go
package mysqlquerybuilder
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"git.gocasts.ir/ebhomengo/niki/param"
|
|
)
|
|
|
|
func BuildGetAllQuery(baseQuery string, filter param.FilterRequest, pagination param.PaginationRequest, sort param.SortRequest) (query string, args []any) {
|
|
filterQuery, fArgs := BuildFilterQuery(filter)
|
|
paginationQuery, pArgs := BuildPaginationQuery(pagination)
|
|
sortQuery := BuildSortQuery(sort)
|
|
|
|
args = append(args, fArgs...)
|
|
args = append(args, pArgs...)
|
|
|
|
query = baseQuery
|
|
if filterQuery != "" {
|
|
query = fmt.Sprintf("%s %s", query, filterQuery)
|
|
}
|
|
if sortQuery != "" {
|
|
query = fmt.Sprintf("%s %s", query, sortQuery)
|
|
}
|
|
if paginationQuery != "" {
|
|
query = fmt.Sprintf("%s %s", query, paginationQuery)
|
|
}
|
|
|
|
return query, args
|
|
}
|