修改curd基本写法

This commit is contained in:
linwenxiang committed 2020-08-29 18:54:39 +08:00
1 parent 55496078f0
commit ca98fd873c
3 files changed
+43 -84

No files matched your search

+10 -2
View File
@@ -175,11 +175,19 @@ func (e *SysTables) Update() (update SysTables, err error) {
}
func (e *SysTables) Delete() (success bool, err error) {
if err = orm.Eloquent.Table("sys_tables").Delete(SysTables{}, "table_id = ?", e.TableId).Error; err != nil {
tx := orm.Eloquent.Begin()
defer func() {
if err != nil {
tx.Rollback()
} else {
tx.Commit()
}
}()
if err = tx.Table("sys_tables").Delete(SysTables{}, "table_id = ?", e.TableId).Error; err != nil {
success = false
return
}
if err = orm.Eloquent.Table("sys_columns").Delete(SysColumns{}, "table_id = ?", e.TableId).Error; err != nil {
if err = tx.Table("sys_columns").Delete(SysColumns{}, "table_id = ?", e.TableId).Error; err != nil {
success = false
return
}