repository.go 1.8 KB
package factory

import (
	"github.com/linmadan/egglib-go/transaction/pg"
	"gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/domain"
	"gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/infrastructure/repository"
)

func CreateTableRepository(options map[string]interface{}) (domain.TableRepository, error) {
	var transactionContext *pg.TransactionContext
	if value, ok := options["transactionContext"]; ok {
		transactionContext = value.(*pg.TransactionContext)
	}
	return repository.NewTableRepository(transactionContext)
}

func CreateLogRepository(options map[string]interface{}) (domain.LogRepository, error) {
	var transactionContext *pg.TransactionContext
	if value, ok := options["transactionContext"]; ok {
		transactionContext = value.(*pg.TransactionContext)
	}
	return repository.NewLogRepository(transactionContext)
}

func CreateFileRepository(options map[string]interface{}) (domain.FileRepository, error) {
	var transactionContext *pg.TransactionContext
	if value, ok := options["transactionContext"]; ok {
		transactionContext = value.(*pg.TransactionContext)
	}
	return repository.NewFileRepository(transactionContext)
}

func CreateMappingRuleRepository(options map[string]interface{}) (domain.MappingRuleRepository, error) {
	var transactionContext *pg.TransactionContext
	if value, ok := options["transactionContext"]; ok {
		transactionContext = value.(*pg.TransactionContext)
	}
	return repository.NewMappingRuleRepository(transactionContext)
}

func CreateQuerySetRepository(options map[string]interface{}) (domain.QuerySetRepository, error) {
	var transactionContext *pg.TransactionContext
	if value, ok := options["transactionContext"]; ok {
		transactionContext = value.(*pg.TransactionContext)
	}
	return repository.NewQuerySetRepository(transactionContext)
}