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