cooperation_mode_controller.go
4.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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
package web_client
import (
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/cooperationMode/command"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/cooperationMode/query"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/cooperationMode/service"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/log"
)
type CooperationModeController struct {
baseController
}
func (controller *CooperationModeController) CreateCooperationMode() {
cooperationModeService := service.NewCooperationModeService(nil)
createCooperationModeCommand := &command.CreateCooperationModeCommand{}
err := controller.Unmarshal(createCooperationModeCommand)
if err != nil {
log.Logger.Debug("json err:" + err.Error())
controller.Response(nil, err)
return
}
createCooperationModeCommand.Operator = controller.GetOperator()
data, err := cooperationModeService.CreateCooperationMode(createCooperationModeCommand)
controller.Response(data, err)
}
func (controller *CooperationModeController) UpdateCooperationMode() {
cooperationModeService := service.NewCooperationModeService(nil)
updateCooperationModeCommand := &command.UpdateCooperationModeCommand{}
err := controller.Unmarshal(updateCooperationModeCommand)
if err != nil {
log.Logger.Debug("json err:" + err.Error())
controller.Response(nil, err)
return
}
modeId, _ := controller.GetInt(":modeId")
updateCooperationModeCommand.Operator = controller.GetOperator()
updateCooperationModeCommand.CooperationModeId = modeId
data, err := cooperationModeService.UpdateCooperationMode(updateCooperationModeCommand)
controller.Response(data, err)
}
func (controller *CooperationModeController) GetCooperationMode() {
cooperationModeService := service.NewCooperationModeService(nil)
getCooperationModeQuery := &query.GetCooperationModeQuery{}
modeId, _ := controller.GetInt(":modeId")
getCooperationModeQuery.CooperationModeId = modeId
getCooperationModeQuery.Operator = controller.GetOperator()
data, err := cooperationModeService.GetCooperationMode(getCooperationModeQuery)
controller.Response(data, err)
}
func (controller *CooperationModeController) RemoveCooperationMode() {
cooperationModeService := service.NewCooperationModeService(nil)
removeCooperationModeCommand := &command.RemoveCooperationModeCommand{}
err := controller.Unmarshal(removeCooperationModeCommand)
if err != nil {
log.Logger.Debug("json err:" + err.Error())
controller.Response(nil, err)
return
}
removeCooperationModeCommand.Operator = controller.GetOperator()
data, err := cooperationModeService.RemoveCooperationMode(removeCooperationModeCommand)
controller.Response(data, err)
}
func (controller *CooperationModeController) SearchCooperationMode() {
cooperationModeService := service.NewCooperationModeService(nil)
listCooperationModeQuery := &query.ListCooperationModeQuery{}
err := controller.Unmarshal(listCooperationModeQuery)
if err != nil {
log.Logger.Debug("json err:" + err.Error())
controller.Response(nil, err)
return
}
listCooperationModeQuery.Operator = controller.GetOperator()
cnt, data, err := cooperationModeService.ListCooperationMode(listCooperationModeQuery)
controller.ReturnPageListData(cnt, data, err, listCooperationModeQuery.PageNumber)
}
func (controller *CooperationModeController) ListCooperationMode() {
cooperationModeService := service.NewCooperationModeService(nil)
listCooperationModeQuery := &query.ListCooperationModeQuery{}
err := controller.Unmarshal(listCooperationModeQuery)
if err != nil {
log.Logger.Debug("json err:" + err.Error())
controller.Response(nil, err)
return
}
listCooperationModeQuery.Operator = controller.GetOperator()
listCooperationModeQuery.PageNumber = 1
listCooperationModeQuery.PageSize = 999
cnt, data, err := cooperationModeService.ListCooperationMode(listCooperationModeQuery)
controller.ReturnListData(cnt, data, err)
}
func (controller *CooperationModeController) EnableCooperationMode() {
cooperationModeService := service.NewCooperationModeService(nil)
removeCooperationModeCommand := &command.OperateCooperationModeCommand{}
err := controller.Unmarshal(removeCooperationModeCommand)
if err != nil {
log.Logger.Debug("json err:" + err.Error())
controller.Response(nil, err)
return
}
removeCooperationModeCommand.Operator = controller.GetOperator()
data, err := cooperationModeService.EnableCooperationMode(removeCooperationModeCommand)
controller.Response(data, err)
}