repository.go 839 字节
package factory

import (
	"github.com/linmadan/egglib-go/transaction/pg"
	"github.com/tiptok/godevp/pkg/domain/role"
	"github.com/tiptok/godevp/pkg/domain/users"
	"github.com/tiptok/godevp/pkg/infrastructure/repository"
)

func CreateUsersRepository(options map[string]interface{}) (users.UsersRepository, error) {
	var transactionContext *pg.TransactionContext
	if value, ok := options["transactionContext"]; ok {
		transactionContext = value.(*pg.TransactionContext)
	}
	return repository.NewUsersRepository(transactionContext)
}

func CreateRoleRepository(options map[string]interface{}) (role.RoleRepository, error) {
	var transactionContext *pg.TransactionContext
	if value, ok := options["transactionContext"]; ok {
		transactionContext = value.(*pg.TransactionContext)
	}
	return repository.NewRoleRepository(transactionContext)
}