From d2c308b0c64e9719d4c30738f0614f221918f13c Mon Sep 17 00:00:00 2001 From: public_host Date: Fri, 23 Apr 2021 18:14:31 +0800 Subject: [PATCH] fix --- hasaki-gen-crud/template.go | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/hasaki-gen-crud/template.go b/hasaki-gen-crud/template.go index 804e541..0dc7087 100644 --- a/hasaki-gen-crud/template.go +++ b/hasaki-gen-crud/template.go @@ -102,16 +102,20 @@ func (TempLowHead3A60 *Temp3A60) Load() (err error) { func (TempLowHead3A60 *Temp3A60) Data() (data []Temp3A60) { q, args := TempLowHead3A60.whereData() _xorm := TempLowHead3A60.getXorm() + session := _xorm.NewSession() + defer func() { + session.Close() + }() if q != "" { - _xorm.Where(q, args...) + session = session.Where(q, args...) } order := TempLowHead3A60.orderData() if order != "" { - _xorm.OrderBy(order) + session = session.OrderBy(order) } - _xorm.Find(&data) + session.Find(&data) for i := range data { data[i].init() } @@ -122,16 +126,20 @@ func (TempLowHead3A60 *Temp3A60) Data() (data []Temp3A60) { func (TempLowHead3A60 *Temp3A60) PageData(page, pageSize int) (data []Temp3A60, count int64) { q, args := TempLowHead3A60.whereData() _xorm := TempLowHead3A60.getXorm() + session := _xorm.NewSession() + defer func() { + session.Close() + }() if q != "" { - _xorm.Where(q, args...) + session = session.Where(q, args...) } order := TempLowHead3A60.orderData() if order != "" { - _xorm.OrderBy(order) + session = session.OrderBy(order) } - count, _ = _xorm.Limit(pageSize, page*pageSize).FindAndCount(&data) + count, _ = session.Limit(pageSize, page*pageSize).FindAndCount(&data) for i := range data { data[i].init() }