repository.go 1.5 KB
package factory

import (
	"github.com/linmadan/egglib-go/transaction/pg"
	"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain"
	"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/infrastructure/repository"
)

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

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

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

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