From cb4b8fe26d2ea4e5780a91cb3ff20f9bdbdf9022 Mon Sep 17 00:00:00 2001 From: guzeng Date: Sat, 6 Mar 2021 13:08:06 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=88=86=E9=A1=B5=E8=AE=A1?= =?UTF-8?q?=E7=AE=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- chain.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/chain.go b/chain.go index 96737f7..5b724c6 100644 --- a/chain.go +++ b/chain.go @@ -64,7 +64,9 @@ func (this *Query) Where(where string) *Query { return this } func (this *Query) Wheres(wheres []string) *Query { - this.where = append(this.where, wheres...) + if len(wheres) > 0 { + this.where = append(this.where, wheres...) + } return this } func (this *Query) WhereOr(where string) *Query { @@ -158,13 +160,13 @@ func (this *Query) QueryStmt() error { if this.page > 0 || this.page_size > 0 { - if this.page < 0 { - this.page = 0 + if this.page < 1 { + this.page = 1 } if this.page_size < 1 { this.page_size = 10 } - from := strconv.Itoa(this.page * this.page_size) + from := strconv.Itoa((this.page - 1) * this.page_size) offset := strconv.Itoa(this.page_size) if from != "" && offset != "" { sql = helper.StringJoin(sql, " limit ", from, " , ", offset)