1
This commit is contained in:
parent
f7213bc8d7
commit
52d292902a
21
dbpool.go
21
dbpool.go
@ -3,6 +3,7 @@ package f5
|
|||||||
import (
|
import (
|
||||||
"q5"
|
"q5"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"math"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -115,6 +116,26 @@ func (this *dbPool) PageQuery(
|
|||||||
var pagination Pagination
|
var pagination Pagination
|
||||||
pagination.PerPage = q5.Max(1, perPage)
|
pagination.PerPage = q5.Max(1, perPage)
|
||||||
pagination.CurrentPage = q5.Max(1, page)
|
pagination.CurrentPage = q5.Max(1, page)
|
||||||
|
finalySql := sql
|
||||||
|
if filter != nil {
|
||||||
|
finalySql += filter.GenSql()
|
||||||
|
}
|
||||||
|
if orderBy != "" {
|
||||||
|
finalySql += " " + orderBy + " "
|
||||||
|
}
|
||||||
|
this.internalQueryOne(
|
||||||
|
dataSource,
|
||||||
|
fmt.Sprintf("SELECT COUNT(*) FROM (%s)", finalySql),
|
||||||
|
params,
|
||||||
|
func (err error, row *[]*string) {
|
||||||
|
if err != nil {
|
||||||
|
cb(err, &pagination)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
pagination.Total = q5.ToInt32(*(*row)[0])
|
||||||
|
pagination.TotalPages = int32(math.Ceil(q5.ToFloat64(*(*row)[0]) /
|
||||||
|
float64(pagination.PerPage)))
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *dbPool) borrowConn(dataSource string) *q5.Mysql {
|
func (this *dbPool) borrowConn(dataSource string) *q5.Mysql {
|
||||||
|
2
types.go
2
types.go
@ -33,7 +33,7 @@ type HandlerFunc func(*Context)
|
|||||||
|
|
||||||
type QueryResultCb func (error, *DataSet);
|
type QueryResultCb func (error, *DataSet);
|
||||||
type QueryOneCb func (error, *[]*string);
|
type QueryOneCb func (error, *[]*string);
|
||||||
type PageQueryCb func (error, Pagination);
|
type PageQueryCb func (error, *Pagination);
|
||||||
type ExecResultCb func (error, int64, int64);
|
type ExecResultCb func (error, int64, int64);
|
||||||
|
|
||||||
type middleware struct {
|
type middleware struct {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user