From ac7e93d772388238311093ef09ac4ce25a9213a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=80=97=E5=AD=90?= Date: Thu, 5 Oct 2023 14:51:44 +0800 Subject: [PATCH] feat: move interface --- contracts/database/gorm/wire_interface.go | 20 +++---------------- database/wire_interface.go | 24 +++++++++++++++++++++++ 2 files changed, 27 insertions(+), 17 deletions(-) create mode 100644 database/wire_interface.go diff --git a/contracts/database/gorm/wire_interface.go b/contracts/database/gorm/wire_interface.go index 5b355be3f..841eeb3ce 100644 --- a/contracts/database/gorm/wire_interface.go +++ b/contracts/database/gorm/wire_interface.go @@ -6,7 +6,7 @@ import ( gormio "gorm.io/gorm" "github.com/goravel/framework/contracts/config" - "github.com/goravel/framework/database/gorm" + "github.com/goravel/framework/contracts/database/orm" ) type Gorm interface { @@ -14,20 +14,6 @@ type Gorm interface { } type Initialize interface { - InitializeGorm(config config.Config, connection string) *gorm.GormImpl - InitializeQuery(ctx context.Context, config config.Config, connection string) (*gorm.QueryImpl, error) -} - -type InitializeImpl struct{} - -func NewInitializeImpl() *InitializeImpl { - return &InitializeImpl{} -} - -func (receive *InitializeImpl) InitializeGorm(config config.Config, connection string) *gorm.GormImpl { - return gorm.InitializeGorm(config, connection) -} - -func (receive *InitializeImpl) InitializeQuery(ctx context.Context, config config.Config, connection string) (*gorm.QueryImpl, error) { - return gorm.InitializeQuery(ctx, config, connection) + InitializeGorm(config config.Config, connection string) Gorm + InitializeQuery(ctx context.Context, config config.Config, connection string) (orm.Query, error) } diff --git a/database/wire_interface.go b/database/wire_interface.go new file mode 100644 index 000000000..a837d7212 --- /dev/null +++ b/database/wire_interface.go @@ -0,0 +1,24 @@ +package database + +import ( + "context" + + "github.com/goravel/framework/contracts/config" + contractsgorm "github.com/goravel/framework/contracts/database/gorm" + "github.com/goravel/framework/contracts/database/orm" + "github.com/goravel/framework/database/gorm" +) + +type InitializeImpl struct{} + +func NewInitializeImpl() *InitializeImpl { + return &InitializeImpl{} +} + +func (receive *InitializeImpl) InitializeGorm(config config.Config, connection string) contractsgorm.Gorm { + return gorm.InitializeGorm(config, connection) +} + +func (receive *InitializeImpl) InitializeQuery(ctx context.Context, config config.Config, connection string) (orm.Query, error) { + return gorm.InitializeQuery(ctx, config, connection) +}