增加数据库数据删除方法

This commit is contained in:
白茶清欢 2023-02-09 11:51:55 +08:00
parent 6a3bacc5db
commit 5144c85076
1 changed files with 11 additions and 0 deletions

11
base.go
View File

@ -7,6 +7,7 @@ package mysql
import (
"errors"
"gorm.io/gorm"
)
@ -43,6 +44,16 @@ func (b *BaseDao) List(dbInstance *gorm.DB, table string, result interface{}, op
return dbInstance.Find(result).Error
}
// Delete 删除数据, 硬删除, 对应 delete语句
//
// Author : go_developer@163.com<白茶清欢>
//
// Date : 11:46 2023/2/9
func (b *BaseDao) Delete(dbInstance *gorm.DB, table string, dataModel interface{}, optionFuncList ...SetOption) (int64, error) {
dbInstance = b.setTxCondition(dbInstance, table, optionFuncList...)
return dbInstance.Delete(dataModel).RowsAffected, dbInstance.Delete(dataModel).Error
}
// Detail 查询详情
//
// Author : go_developer@163.com<白茶清欢>