Skip to content

Commit 674e972

Browse files
committed
Rename files
1 parent f151124 commit 674e972

3 files changed

Lines changed: 2 additions & 25 deletions

File tree

File renamed without changes.

query.go

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -17,33 +17,10 @@ const (
1717
asc = "asc"
1818
)
1919

20-
func GetOffset(limit int64, page int64, opts...int64) int64 {
21-
var firstLimit int64 = 0
22-
if len(opts) > 0 && opts[0] > 0 {
23-
firstLimit = opts[0]
24-
}
25-
if firstLimit > 0 {
26-
if page <= 1 {
27-
return 0
28-
} else {
29-
offset := limit*(page-2) + firstLimit
30-
if offset < 0 {
31-
return 0
32-
}
33-
return offset
34-
}
35-
} else {
36-
offset := limit * (page - 1)
37-
if offset < 0 {
38-
return 0
39-
}
40-
return offset
41-
}
42-
}
4320
func BuildFromQuery(ctx context.Context, db *sql.DB, fieldsIndex map[string]int, models interface{}, query string, params []interface{}, limit int64, offset int64, toArray func(interface{}) interface {
4421
driver.Valuer
4522
sql.Scanner
46-
}, options...func(context.Context, interface{}) (interface{}, error)) (int64, error) {
23+
}, options ...func(context.Context, interface{}) (interface{}, error)) (int64, error) {
4724
var mp func(context.Context, interface{}) (interface{}, error)
4825
if len(options) > 0 && options[0] != nil {
4926
mp = options[0]
@@ -110,7 +87,7 @@ func BuildPagingQueryByDriver(sql string, limit int64, offset int64, driver stri
11087
return s2
11188
}
11289
}
113-
func BuildPagingQuery(sql string, limit int64, offset int64, opts...string) string {
90+
func BuildPagingQuery(sql string, limit int64, offset int64, opts ...string) string {
11491
if offset < 0 {
11592
offset = 0
11693
}
File renamed without changes.

0 commit comments

Comments
 (0)