repository.go 2.8 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)
}

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

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

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

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