public_host 4 years ago
parent
commit
955a517a86
  1. 8
      hasaki-gen-crud/template.go

8
hasaki-gen-crud/template.go

@ -12,7 +12,7 @@ type Temp3A60 struct {
// ----------------------------temp------------------------------------
func (TempLowHead3A60 *Temp3A60) where() (q interface{}, args []interface{}) {
func (TempLowHead3A60 *Temp3A60) wherePrimaryKey() (q interface{}, args []interface{}) {
//todo 根据需求修改
return "`id`=?", []interface{}{
TempLowHead3A60.Id,
@ -25,7 +25,7 @@ func (TempLowHead3A60 *Temp3A60) getXorm() *xorm.Engine {
func (TempLowHead3A60 *Temp3A60) Save(isAllCols ...bool) (err error) {
tmp := Temp3A60{}
whereQuery, whereArgs := TempLowHead3A60.where()
whereQuery, whereArgs := TempLowHead3A60.wherePrimaryKey()
TempLowHead3A60.getXorm().Where(whereQuery, whereArgs...).Get(&tmp)
if tmp.Id == 0 {
_, err = TempLowHead3A60.getXorm().Insert(TempLowHead3A60)
@ -40,7 +40,7 @@ func (TempLowHead3A60 *Temp3A60) Save(isAllCols ...bool) (err error) {
}
func (TempLowHead3A60 *Temp3A60) Load() (err error) {
whereQuery, whereArgs := TempLowHead3A60.where()
whereQuery, whereArgs := TempLowHead3A60.wherePrimaryKey()
_, err = TempLowHead3A60.getXorm().Where(whereQuery, whereArgs...).Get(&TempLowHead3A60)
return
}
@ -56,7 +56,7 @@ func (TempLowHead3A60 *Temp3A60) PageData(page, pageSize int) (data []Temp3A60,
}
func (TempLowHead3A60 *Temp3A60) Delete() (err error) {
whereQuery, whereArgs := TempLowHead3A60.where()
whereQuery, whereArgs := TempLowHead3A60.wherePrimaryKey()
_, err = TempLowHead3A60.getXorm().Where(whereQuery, whereArgs...).Delete(&TempLowHead3A60)
return
}

Loading…
Cancel
Save