|
|
package service
|
|
|
|
|
|
import (
|
|
|
"fmt"
|
|
|
|
|
|
"github.com/linmadan/egglib-go/core/application"
|
|
|
"github.com/linmadan/egglib-go/utils/tool_funs"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-basic/pkg/application/dictionary/command"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-basic/pkg/application/dictionary/query"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-basic/pkg/application/factory"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-basic/pkg/domain"
|
|
|
)
|
|
|
|
|
|
// 数据字典设置
|
...
|
...
|
@@ -27,10 +30,8 @@ func (dictionaryService *DictionaryService) CreateDictionary(createDictionaryCom |
|
|
defer func() {
|
|
|
transactionContext.RollbackTransaction()
|
|
|
}()
|
|
|
newDictionary := &dictionary.Dictionary{
|
|
|
Dictionary: createDictionaryCommand.Dictionary,
|
|
|
}
|
|
|
var dictionaryRepository dictionary.DictionaryRepository
|
|
|
newDictionary := &domain.Dictionary{} //TODO
|
|
|
var dictionaryRepository domain.DictionaryRepository
|
|
|
if value, err := factory.CreateDictionaryRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
}); err != nil {
|
...
|
...
|
@@ -63,7 +64,7 @@ func (dictionaryService *DictionaryService) GetDictionary(getDictionaryQuery *qu |
|
|
defer func() {
|
|
|
transactionContext.RollbackTransaction()
|
|
|
}()
|
|
|
var dictionaryRepository dictionary.DictionaryRepository
|
|
|
var dictionaryRepository domain.DictionaryRepository
|
|
|
if value, err := factory.CreateDictionaryRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
}); err != nil {
|
...
|
...
|
@@ -71,12 +72,12 @@ func (dictionaryService *DictionaryService) GetDictionary(getDictionaryQuery *qu |
|
|
} else {
|
|
|
dictionaryRepository = value
|
|
|
}
|
|
|
dictionary, err := dictionaryRepository.FindOne(map[string]interface{}{"dictionaryId": getDictionaryQuery.DictionaryId})
|
|
|
dictionary, err := dictionaryRepository.FindOne(map[string]interface{}{"dictionaryId": getDictionaryQuery.DictCode})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
if dictionary == nil {
|
|
|
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(getDictionaryQuery.DictionaryId)))
|
|
|
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(getDictionaryQuery.DictCode)))
|
|
|
} else {
|
|
|
if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
...
|
...
|
@@ -100,7 +101,7 @@ func (dictionaryService *DictionaryService) ListDictionary(listDictionaryQuery * |
|
|
defer func() {
|
|
|
transactionContext.RollbackTransaction()
|
|
|
}()
|
|
|
var dictionaryRepository dictionary.DictionaryRepository
|
|
|
var dictionaryRepository domain.DictionaryRepository
|
|
|
if value, err := factory.CreateDictionaryRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
}); err != nil {
|
...
|
...
|
@@ -136,7 +137,7 @@ func (dictionaryService *DictionaryService) RemoveDictionary(removeDictionaryCom |
|
|
defer func() {
|
|
|
transactionContext.RollbackTransaction()
|
|
|
}()
|
|
|
var dictionaryRepository dictionary.DictionaryRepository
|
|
|
var dictionaryRepository domain.DictionaryRepository
|
|
|
if value, err := factory.CreateDictionaryRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
}); err != nil {
|
...
|
...
|
@@ -176,7 +177,7 @@ func (dictionaryService *DictionaryService) UpdateDictionary(updateDictionaryCom |
|
|
defer func() {
|
|
|
transactionContext.RollbackTransaction()
|
|
|
}()
|
|
|
var dictionaryRepository dictionary.DictionaryRepository
|
|
|
var dictionaryRepository domain.DictionaryRepository
|
|
|
if value, err := factory.CreateDictionaryRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
}); err != nil {
|
...
|
...
|
|