service.go
3.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
package service
import (
"strconv"
"github.com/linmadan/egglib-go/core/application"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/background/dictionary/command"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/background/dictionary/query"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_basic"
)
// 字典服务
type DictionayService struct {
}
func NewDictionayService(options map[string]interface{}) *DictionayService {
return &DictionayService{}
}
// 创建字典
func (dictionaryService *DictionayService) CreateDictionay(createCommand *command.CreateDictionaryCommand) (interface{}, error) {
creationBasicGateway := allied_creation_basic.NewHttplibAlliedCreationBasic(
createCommand.Operator)
result, err := creationBasicGateway.DictionaryAdd(allied_creation_basic.ReqDictionaryAdd{
DictCode: createCommand.DictCode,
DictName: createCommand.DictName,
Describe: createCommand.Describe,
DictItems: createCommand.DictItems,
})
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
return result, nil
}
// 更新字典
func (dictionaryService *DictionayService) UpdateDictionay(updateCommand *command.UpdateDictionaryCommand) (interface{}, error) {
creationBasicGateway := allied_creation_basic.NewHttplibAlliedCreationBasic(
updateCommand.Operator)
result, err := creationBasicGateway.DictionaryUpdate(allied_creation_basic.ReqDictionaryUpdate{
DictionaryId: updateCommand.DictionaryId,
DictCode: updateCommand.DictCode,
DictName: updateCommand.DictName,
Describe: updateCommand.Describe,
DictItems: updateCommand.DictItems,
})
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
return result, nil
}
//获取字典
func (dictionaryService *DictionayService) GetDictionay(getQuery *query.GetDictionaryQuery) (interface{}, error) {
creationBasicGateway := allied_creation_basic.NewHttplibAlliedCreationBasic(
getQuery.Operator)
result, err := creationBasicGateway.DictionaryGet(allied_creation_basic.ReqDictionaryGet{
DictionaryId: getQuery.DictionaryId,
})
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
return result, nil
}
//获取字典
func (dictionaryService *DictionayService) RemoveDictionay(removeCommand *command.RemoveDictionaryCommand) (interface{}, error) {
creationBasicGateway := allied_creation_basic.NewHttplibAlliedCreationBasic(
removeCommand.Operator)
var dictionaryIds []int
for _, v := range removeCommand.DictionaryIds {
id, _ := strconv.Atoi(v)
dictionaryIds = append(dictionaryIds, id)
}
result, err := creationBasicGateway.DictionaryRemove(allied_creation_basic.ReqDictionaryRemove{
DictionaryIds: dictionaryIds,
})
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
return result, nil
}
//获取字典
func (dictionaryService *DictionayService) ListDictionay(searchQuery *query.ListDictionaryQuery) (interface{}, error) {
creationBasicGateway := allied_creation_basic.NewHttplibAlliedCreationBasic(
searchQuery.Operator)
result, err := creationBasicGateway.DictionarySearch(allied_creation_basic.ReqDictionarySearch{
Pageindex: searchQuery.Pageindex,
PageSize: searchQuery.PageSize,
})
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
return result, nil
}