public_host 4 years ago
parent
commit
421ce4a4b6
  1. 19
      hasaki-gen-crud/template.go

19
hasaki-gen-crud/template.go

@ -37,6 +37,11 @@ func (TempLowHead3A60 *Temp3A60) init() {
//todo
}
//saveAllCols 保存时是否全量保存
func (TempLowHead3A60 *Temp3A60) isSaveAllCols() bool {
return false
}
//savePretreatment 保存前预处理
func (TempLowHead3A60 *Temp3A60) savePretreatment() {
//todo
@ -58,10 +63,18 @@ func (TempLowHead3A60 *Temp3A60) Save(isAllCols ...bool) (err error) {
if tmp.Id == 0 {
_, err = TempLowHead3A60.getXorm().Insert(TempLowHead3A60)
} else {
if len(isAllCols) > 0 && isAllCols[0] {
_, err = TempLowHead3A60.getXorm().AllCols().Where(whereQuery, whereArgs...).Update(TempLowHead3A60)
if len(isAllCols) > 0 {
if isAllCols[0] {
_, err = TempLowHead3A60.getXorm().AllCols().Where(whereQuery, whereArgs...).Update(TempLowHead3A60)
} else {
_, err = TempLowHead3A60.getXorm().Where(whereQuery, whereArgs...).Update(TempLowHead3A60)
}
} else {
_, err = TempLowHead3A60.getXorm().Where(whereQuery, whereArgs...).Update(TempLowHead3A60)
if TempLowHead3A60.isSaveAllCols() {
_, err = TempLowHead3A60.getXorm().AllCols().Where(whereQuery, whereArgs...).Update(TempLowHead3A60)
} else {
_, err = TempLowHead3A60.getXorm().Where(whereQuery, whereArgs...).Update(TempLowHead3A60)
}
}
}
return err

Loading…
Cancel
Save