From 421ce4a4b679461de12a7300f8168133b361df5f Mon Sep 17 00:00:00 2001 From: public_host Date: Tue, 20 Apr 2021 17:30:10 +0800 Subject: [PATCH] fix --- hasaki-gen-crud/template.go | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/hasaki-gen-crud/template.go b/hasaki-gen-crud/template.go index 0ae3e97..0c3f317 100644 --- a/hasaki-gen-crud/template.go +++ b/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