From 5144c850767ba80ee89bd7c602174854b53b635b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E8=8C=B6=E6=B8=85=E6=AC=A2?= Date: Thu, 9 Feb 2023 11:51:55 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=95=B0=E6=8D=AE=E5=BA=93?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=88=A0=E9=99=A4=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- base.go | 11 +++++++++++ 1 file changed, 11 insertions(+) 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<白茶清欢>