Add
This commit is contained in:
parent
1a8c40f038
commit
7fa1685792
25
dbpool.go
25
dbpool.go
@ -1,13 +1,13 @@
|
|||||||
package f5
|
package f5
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"q5"
|
"errors"
|
||||||
"time"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"math"
|
"math"
|
||||||
|
"q5"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"errors"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
type DBStyle int32
|
type DBStyle int32
|
||||||
@ -162,14 +162,16 @@ func (this *dbPool) PageQuery(
|
|||||||
dataSource,
|
dataSource,
|
||||||
fmt.Sprintf("SELECT COUNT(*) FROM (%s)", finalySql),
|
fmt.Sprintf("SELECT COUNT(*) FROM (%s)", finalySql),
|
||||||
params,
|
params,
|
||||||
func (err error, row *[]*string) {
|
func(err error, rows *DataSet) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cb(err, &pagination)
|
cb(err, &pagination)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
pagination.Total = q5.ToInt32(*(*row)[0])
|
if rows != nil && rows.Next() {
|
||||||
pagination.TotalPages = int32(math.Ceil(q5.ToFloat64(*(*row)[0]) /
|
pagination.Total = q5.ToInt32(*rows.GetByIndex(0))
|
||||||
|
pagination.TotalPages = int32(math.Ceil(q5.ToFloat64(*rows.GetByIndex(0)) /
|
||||||
float64(pagination.PerPage)))
|
float64(pagination.PerPage)))
|
||||||
|
}
|
||||||
start := pagination.PerPage * (pagination.CurrentPage - 1)
|
start := pagination.PerPage * (pagination.CurrentPage - 1)
|
||||||
limit := pagination.PerPage
|
limit := pagination.PerPage
|
||||||
this.internalQuery(
|
this.internalQuery(
|
||||||
@ -335,19 +337,16 @@ func (this *dbPool) internalQueryOne(dataSource string, sql string, params []str
|
|||||||
rows, err := ds.conn.Query(sql, q5.ToInterfaces(params)...)
|
rows, err := ds.conn.Query(sql, q5.ToInterfaces(params)...)
|
||||||
this.returnConn(ds)
|
this.returnConn(ds)
|
||||||
|
|
||||||
values := &[]*string{}
|
var dataSet *DataSet
|
||||||
if err == nil {
|
if err == nil {
|
||||||
dataSet := NewDataSet(rows)
|
dataSet = NewDataSet(rows)
|
||||||
if dataSet.Next() {
|
|
||||||
values = dataSet.GetValues()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if this.style == GO_STYLE_DB {
|
if this.style == GO_STYLE_DB {
|
||||||
cb(err, values)
|
cb(err, dataSet)
|
||||||
} else {
|
} else {
|
||||||
_app.RegisterMainThreadCb(
|
_app.RegisterMainThreadCb(
|
||||||
func() {
|
func() {
|
||||||
cb(err, values)
|
cb(err, dataSet)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
12
types.go
12
types.go
@ -11,7 +11,6 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type MsgNode struct {
|
type MsgNode struct {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type IMMsgNode struct {
|
type IMMsgNode struct {
|
||||||
@ -30,10 +29,13 @@ type Pagination struct {
|
|||||||
|
|
||||||
type HandlerFunc func(*Context)
|
type HandlerFunc func(*Context)
|
||||||
|
|
||||||
type QueryResultCb func (error, *DataSet);
|
type QueryResultCb func(error, *DataSet)
|
||||||
type QueryOneCb func (error, *[]*string);
|
|
||||||
type PageQueryCb func (error, *Pagination);
|
type QueryOneCb func(error, *DataSet)
|
||||||
type ExecResultCb func (error, int64, int64);
|
|
||||||
|
type PageQueryCb func(error, *Pagination)
|
||||||
|
|
||||||
|
type ExecResultCb func(error, int64, int64)
|
||||||
|
|
||||||
type middleware struct {
|
type middleware struct {
|
||||||
middlewareType int32
|
middlewareType int32
|
||||||
|
Loading…
x
Reference in New Issue
Block a user