|
|
@@ -1,6 +1,8 @@
|
|
|
package value_object_crud
|
|
|
|
|
|
import (
|
|
|
+ "reflect"
|
|
|
+
|
|
|
"git.sxidc.com/go-framework/baize/framework/binding"
|
|
|
"git.sxidc.com/go-framework/baize/framework/core/api"
|
|
|
"git.sxidc.com/go-framework/baize/framework/core/api/request"
|
|
|
@@ -12,7 +14,6 @@ import (
|
|
|
"git.sxidc.com/go-framework/baize/framework/core/infrastructure/database/sql"
|
|
|
"git.sxidc.com/go-framework/baize/framework/core/tag/sql/sql_mapping"
|
|
|
"github.com/pkg/errors"
|
|
|
- "reflect"
|
|
|
)
|
|
|
|
|
|
func Create(tableName string, callbacks *CreateCallbacks, needTx bool) binding.ServiceFunc[any] {
|
|
|
@@ -90,7 +91,7 @@ func Create(tableName string, callbacks *CreateCallbacks, needTx bool) binding.S
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-func Delete(tableName string, callbacks *DeleteCallbacks, needTx bool) binding.ServiceFunc[any] {
|
|
|
+func Delete(tableName string, callbacks *DeleteCallbacks, needTx bool, scopeFields ...string) binding.ServiceFunc[any] {
|
|
|
return func(c *api.Context, params request.Params, objects []domain.Object, i *infrastructure.Infrastructure) (any, error) {
|
|
|
object := objects[0]
|
|
|
if object == nil {
|
|
|
@@ -121,7 +122,7 @@ func Delete(tableName string, callbacks *DeleteCallbacks, needTx bool) binding.S
|
|
|
return err
|
|
|
}
|
|
|
|
|
|
- err = database.DeleteEntity(tx, tableName, valueObject)
|
|
|
+ err = database.DeleteEntityWithScope(tx, tableName, valueObject, scopeFields...)
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
|
@@ -142,7 +143,7 @@ func Delete(tableName string, callbacks *DeleteCallbacks, needTx bool) binding.S
|
|
|
return nil, callbackOnDeleteErrorReturn(callbacks, c, params, valueObject, make(map[string]any), err, i)
|
|
|
}
|
|
|
|
|
|
- err = database.DeleteEntity(dbExecutor, tableName, valueObject)
|
|
|
+ err = database.DeleteEntityWithScope(dbExecutor, tableName, valueObject, scopeFields...)
|
|
|
if err != nil {
|
|
|
return nil, callbackOnDeleteErrorReturn(callbacks, c, params, valueObject, make(map[string]any), err, i)
|
|
|
}
|