public_host 4 years ago
parent
commit
d2c308b0c6
  1. 20
      hasaki-gen-crud/template.go

20
hasaki-gen-crud/template.go

@ -102,16 +102,20 @@ func (TempLowHead3A60 *Temp3A60) Load() (err error) {
func (TempLowHead3A60 *Temp3A60) Data() (data []Temp3A60) { func (TempLowHead3A60 *Temp3A60) Data() (data []Temp3A60) {
q, args := TempLowHead3A60.whereData() q, args := TempLowHead3A60.whereData()
_xorm := TempLowHead3A60.getXorm() _xorm := TempLowHead3A60.getXorm()
session := _xorm.NewSession()
defer func() {
session.Close()
}()
if q != "" { if q != "" {
_xorm.Where(q, args...)
session = session.Where(q, args...)
} }
order := TempLowHead3A60.orderData() order := TempLowHead3A60.orderData()
if order != "" { if order != "" {
_xorm.OrderBy(order)
session = session.OrderBy(order)
} }
_xorm.Find(&data)
session.Find(&data)
for i := range data { for i := range data {
data[i].init() data[i].init()
} }
@ -122,16 +126,20 @@ func (TempLowHead3A60 *Temp3A60) Data() (data []Temp3A60) {
func (TempLowHead3A60 *Temp3A60) PageData(page, pageSize int) (data []Temp3A60, count int64) { func (TempLowHead3A60 *Temp3A60) PageData(page, pageSize int) (data []Temp3A60, count int64) {
q, args := TempLowHead3A60.whereData() q, args := TempLowHead3A60.whereData()
_xorm := TempLowHead3A60.getXorm() _xorm := TempLowHead3A60.getXorm()
session := _xorm.NewSession()
defer func() {
session.Close()
}()
if q != "" { if q != "" {
_xorm.Where(q, args...)
session = session.Where(q, args...)
} }
order := TempLowHead3A60.orderData() order := TempLowHead3A60.orderData()
if order != "" { 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 { for i := range data {
data[i].init() data[i].init()
} }

Loading…
Cancel
Save