From 865e2e572543b0afd013ebdf7ede4a118b95e679 Mon Sep 17 00:00:00 2001 From: xing Date: Fri, 16 Sep 2022 18:06:50 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- models/model.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/models/model.go b/models/model.go index 92fd8f0..909ca6d 100644 --- a/models/model.go +++ b/models/model.go @@ -4,8 +4,10 @@ import ( "fmt" "github/fthvgb1/wp-go/db" "github/fthvgb1/wp-go/helper" + "math/rand" "strconv" "strings" + "time" ) type Model interface { @@ -141,8 +143,9 @@ func SimplePagination[T Model](where ParseWhere, fields, group string, page, pag sq := fmt.Sprintf(tpx, rr.Table(), j, w) err = db.Db.Get(&n, sq, args...) } else { - tpx := "select count(*) n from (select %s from %s %s %s %s ) tx" - sq := fmt.Sprintf(tpx, group, rr.Table(), j, w, groupBy) + tpx := "select count(*) n from (select %s from %s %s %s %s ) %s" + rand.Seed(int64(time.Now().Nanosecond())) + sq := fmt.Sprintf(tpx, group, rr.Table(), j, w, groupBy, fmt.Sprintf("table%d", rand.Int())) err = db.Db.Get(&n, sq, args...) }