diff --git a/base.go b/base.go index a979ed3..6003e67 100644 --- a/base.go +++ b/base.go @@ -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<白茶清欢>