|
|
package repository
|
|
|
|
|
|
import (
|
|
|
|
|
|
"github.com/linmadan/egglib-go/persistent/pg/sqlbuilder"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/domain"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/infrastructure/utils"
|
|
|
)
|
|
|
|
|
|
func WhereContext(query *sqlbuilder.Query, queryOptions map[string]interface{}) *sqlbuilder.Query{
|
|
|
func WhereContext(query *sqlbuilder.Query, queryOptions map[string]interface{}) *sqlbuilder.Query {
|
|
|
if _, ok := queryOptions["context"]; !ok {
|
|
|
return query
|
|
|
}
|
...
|
...
|
@@ -16,15 +15,14 @@ func WhereContext(query *sqlbuilder.Query, queryOptions map[string]interface{}) |
|
|
return query
|
|
|
}
|
|
|
|
|
|
|
|
|
func SetOffsetAndLimit(query *sqlbuilder.Query, queryOptions map[string]interface{},defaultLimit int) {
|
|
|
pageNumber,pnOk:=queryOptions["pageNumber"]
|
|
|
pageSize,psOk :=queryOptions["pageSize"]
|
|
|
if pnOk && psOk{
|
|
|
iPageNumber:=utils.NumberString(utils.AssertString(pageNumber)).MustInt()
|
|
|
iPageSize:=utils.NumberString(utils.AssertString(pageSize)).MustInt()
|
|
|
func SetOffsetAndLimit(query *sqlbuilder.Query, queryOptions map[string]interface{}, defaultLimit int) {
|
|
|
pageNumber, pnOk := queryOptions["pageNumber"]
|
|
|
pageSize, psOk := queryOptions["pageSize"]
|
|
|
if pnOk && psOk {
|
|
|
iPageNumber := utils.NumberString(utils.AssertString(pageNumber)).MustInt()
|
|
|
iPageSize := utils.NumberString(utils.AssertString(pageSize)).MustInt()
|
|
|
queryOptions["limit"] = iPageSize
|
|
|
queryOptions["offset"] = (iPageSize*(iPageNumber-1))
|
|
|
queryOptions["offset"] = (iPageSize * (iPageNumber - 1))
|
|
|
}
|
|
|
query.SetOffsetAndLimit(defaultLimit)
|
|
|
} |
...
|
...
|
|