public_host 4 years ago
parent
commit
bdd1993bda
  1. 18
      hasaki-gen-crud/template.go

18
hasaki-gen-crud/template.go

@ -43,8 +43,15 @@ func (TempLowHead3A60 *Temp3A60) isSaveAllCols() bool {
} }
//savePretreatment 保存前预处理 //savePretreatment 保存前预处理
func (TempLowHead3A60 *Temp3A60) savePretreatment() {
func (TempLowHead3A60 *Temp3A60) savePretreatment() error {
//todo //todo
return nil
}
//savePretreatment 保存前预处理
func (TempLowHead3A60 *Temp3A60) deletePretreatment() error {
//todo
return nil
} }
func (TempLowHead3A60 *Temp3A60) getXorm() *xorm.Engine { func (TempLowHead3A60 *Temp3A60) getXorm() *xorm.Engine {
@ -59,7 +66,10 @@ func (TempLowHead3A60 *Temp3A60) Save(isAllCols ...bool) (err error) {
tmp := Temp3A60{} tmp := Temp3A60{}
whereQuery, whereArgs := TempLowHead3A60.wherePrimaryKey() whereQuery, whereArgs := TempLowHead3A60.wherePrimaryKey()
TempLowHead3A60.getXorm().Where(whereQuery, whereArgs...).Get(&tmp) TempLowHead3A60.getXorm().Where(whereQuery, whereArgs...).Get(&tmp)
TempLowHead3A60.savePretreatment()
err = TempLowHead3A60.savePretreatment()
if err != nil {
return
}
if tmp.Id == 0 { if tmp.Id == 0 {
_, err = TempLowHead3A60.getXorm().Insert(TempLowHead3A60) _, err = TempLowHead3A60.getXorm().Insert(TempLowHead3A60)
} else { } else {
@ -131,6 +141,10 @@ func (TempLowHead3A60 *Temp3A60) PageData(page, pageSize int) (data []Temp3A60,
//Delete 删除数据 //Delete 删除数据
func (TempLowHead3A60 *Temp3A60) Delete() (err error) { func (TempLowHead3A60 *Temp3A60) Delete() (err error) {
whereQuery, whereArgs := TempLowHead3A60.wherePrimaryKey() whereQuery, whereArgs := TempLowHead3A60.wherePrimaryKey()
err = TempLowHead3A60.deletePretreatment()
if err != nil {
return
}
_, err = TempLowHead3A60.getXorm().Where(whereQuery, whereArgs...).Delete(TempLowHead3A60) _, err = TempLowHead3A60.getXorm().Where(whereQuery, whereArgs...).Delete(TempLowHead3A60)
return return
} }

Loading…
Cancel
Save