1
|
package repository
|
1
|
package repository
|
2
|
|
2
|
|
3
|
import (
|
3
|
import (
|
4
|
-
|
|
|
5
|
"github.com/linmadan/egglib-go/persistent/pg/sqlbuilder"
|
4
|
"github.com/linmadan/egglib-go/persistent/pg/sqlbuilder"
|
6
|
"gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/domain"
|
5
|
"gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/domain"
|
7
|
"gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/infrastructure/utils"
|
6
|
"gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/infrastructure/utils"
|
8
|
)
|
7
|
)
|
9
|
|
8
|
|
10
|
-func WhereContext(query *sqlbuilder.Query, queryOptions map[string]interface{}) *sqlbuilder.Query{
|
9
|
+func WhereContext(query *sqlbuilder.Query, queryOptions map[string]interface{}) *sqlbuilder.Query {
|
11
|
if _, ok := queryOptions["context"]; !ok {
|
10
|
if _, ok := queryOptions["context"]; !ok {
|
12
|
return query
|
11
|
return query
|
13
|
}
|
12
|
}
|
|
@@ -16,15 +15,14 @@ func WhereContext(query *sqlbuilder.Query, queryOptions map[string]interface{}) |
|
@@ -16,15 +15,14 @@ func WhereContext(query *sqlbuilder.Query, queryOptions map[string]interface{}) |
16
|
return query
|
15
|
return query
|
17
|
}
|
16
|
}
|
18
|
|
17
|
|
19
|
-
|
|
|
20
|
-func SetOffsetAndLimit(query *sqlbuilder.Query, queryOptions map[string]interface{},defaultLimit int) {
|
|
|
21
|
- pageNumber,pnOk:=queryOptions["pageNumber"]
|
|
|
22
|
- pageSize,psOk :=queryOptions["pageSize"]
|
|
|
23
|
- if pnOk && psOk{
|
|
|
24
|
- iPageNumber:=utils.NumberString(utils.AssertString(pageNumber)).MustInt()
|
|
|
25
|
- iPageSize:=utils.NumberString(utils.AssertString(pageSize)).MustInt()
|
18
|
+func SetOffsetAndLimit(query *sqlbuilder.Query, queryOptions map[string]interface{}, defaultLimit int) {
|
|
|
19
|
+ pageNumber, pnOk := queryOptions["pageNumber"]
|
|
|
20
|
+ pageSize, psOk := queryOptions["pageSize"]
|
|
|
21
|
+ if pnOk && psOk {
|
|
|
22
|
+ iPageNumber := utils.NumberString(utils.AssertString(pageNumber)).MustInt()
|
|
|
23
|
+ iPageSize := utils.NumberString(utils.AssertString(pageSize)).MustInt()
|
26
|
queryOptions["limit"] = iPageSize
|
24
|
queryOptions["limit"] = iPageSize
|
27
|
- queryOptions["offset"] = (iPageSize*(iPageNumber-1))
|
25
|
+ queryOptions["offset"] = (iPageSize * (iPageNumber - 1))
|
28
|
}
|
26
|
}
|
29
|
query.SetOffsetAndLimit(defaultLimit)
|
27
|
query.SetOffsetAndLimit(defaultLimit)
|
30
|
} |
28
|
} |