dictionary_controller.go
2.6 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
package backgroud_client
import (
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/log"
"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/application/background/dictionary/service"
)
type DictionaryController struct {
baseController
}
func (controller *DictionaryController) CreateDictionary() {
dictionaryService := service.NewDictionayService(nil)
createCommand := &command.CreateDictionaryCommand{}
err := controller.Unmarshal(createCommand)
if err != nil {
log.Logger.Debug("json err:" + err.Error())
}
createCommand.Operator = controller.GetOperator()
data, err := dictionaryService.CreateDictionay(createCommand)
controller.Response(data, err)
}
func (controller *DictionaryController) UpdateDictionary() {
dictionaryService := service.NewDictionayService(nil)
updateCommand := &command.UpdateDictionaryCommand{}
err := controller.Unmarshal(updateCommand)
if err != nil {
log.Logger.Debug("json err:" + err.Error())
}
dictionaryId, _ := controller.GetInt64("::dictionaryId")
updateCommand.Operator = controller.GetOperator()
updateCommand.DictionaryId = dictionaryId
data, err := dictionaryService.UpdateDictionay(updateCommand)
controller.Response(data, err)
}
func (controller *DictionaryController) RemoveDictionary() {
dictionaryService := service.NewDictionayService(nil)
removeCommand := &command.RemoveDictionaryCommand{}
err := controller.Unmarshal(removeCommand)
if err != nil {
log.Logger.Debug("json err:" + err.Error())
}
removeCommand.Operator = controller.GetOperator()
data, err := dictionaryService.RemoveDictionay(removeCommand)
controller.Response(data, err)
}
func (controller *DictionaryController) GetDictionary() {
dictionaryService := service.NewDictionayService(nil)
getQuery := &query.GetDictionaryQuery{}
dictionaryId, _ := controller.GetInt64("::dictionaryId")
getQuery.DictionaryId = int(dictionaryId)
getQuery.Operator = controller.GetOperator()
data, err := dictionaryService.GetDictionay(getQuery)
controller.Response(data, err)
}
func (controller *DictionaryController) ListDictionary() {
dictionaryService := service.NewDictionayService(nil)
listQuery := &query.ListDictionaryQuery{}
err := controller.Unmarshal(listQuery)
if err != nil {
log.Logger.Debug("json err:" + err.Error())
}
listQuery.Operator = controller.GetOperator()
data, err := dictionaryService.ListDictionay(listQuery)
controller.Response(data, err)
}