Skip to content

Commit

Permalink
feat: move interface
Browse files Browse the repository at this point in the history
  • Loading branch information
devhaozi committed Oct 5, 2023
1 parent 3be061b commit ac7e93d
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 17 deletions.
20 changes: 3 additions & 17 deletions contracts/database/gorm/wire_interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,14 @@ 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 {
Make() (*gormio.DB, error)
}

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)
}
24 changes: 24 additions & 0 deletions database/wire_interface.go
Original file line number Diff line number Diff line change
@@ -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)
}

0 comments on commit ac7e93d

Please sign in to comment.