forked from ebhomengo/niki
1
0
Fork 0
niki/pkg/query_builder/mysql/get_all.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
}