...
|
...
|
@@ -253,6 +253,47 @@ func (dictionaryService *DictionaryService) UpdateDictionary(updateDictionaryCom |
|
|
}
|
|
|
}
|
|
|
|
|
|
// 返回数据字典设置
|
|
|
func (dictionaryService *DictionaryService) GetDictionaryByCode(getDictionaryQuery *query.GetDictionaryByCodeQuery) (interface{}, error) {
|
|
|
if err := getDictionaryQuery.ValidateQuery(); err != nil {
|
|
|
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
|
|
|
}
|
|
|
transactionContext, err := factory.CreateTransactionContext(nil)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
if err := transactionContext.StartTransaction(); err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
defer func() {
|
|
|
transactionContext.RollbackTransaction()
|
|
|
}()
|
|
|
var dictionaryRepository domain.DictionaryRepository
|
|
|
if value, err := factory.CreateDictionaryRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
}); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
} else {
|
|
|
dictionaryRepository = value
|
|
|
}
|
|
|
queryCondition := make(map[string]interface{})
|
|
|
if len(getDictionaryQuery.DictCodes) > 0 {
|
|
|
queryCondition["dictCodeIn"] = getDictionaryQuery.DictCodes
|
|
|
}
|
|
|
_, dictionarys, err := dictionaryRepository.Find(queryCondition)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
|
|
|
if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
return map[string]interface{}{
|
|
|
"dictionarys": dictionarys,
|
|
|
}, nil
|
|
|
|
|
|
}
|
|
|
|
|
|
func NewDictionaryService(options map[string]interface{}) *DictionaryService {
|
|
|
newDictionaryService := &DictionaryService{}
|
|
|
return newDictionaryService
|
...
|
...
|
|