forked from ebhomengo/niki
32 lines
738 B
Go
32 lines
738 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) (string, []any) {
|
|
|
|
filterQuery, fArgs := BuildFilterQuery(filter)
|
|
paginationQuery, pArgs := BuildPaginationQuery(pagination)
|
|
sortQuery := BuildSortQuery(sort)
|
|
|
|
args := []any{}
|
|
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
|
|
}
|