cooperation_project_controller.go
4.3 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
package web_client
import (
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/cooperationProject/command"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/cooperationProject/query"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/cooperationProject/service"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/log"
)
type CooperationProjectController struct {
baseController
}
func (controller *CooperationProjectController) CreateCooperationProject() {
cooperationProjectService := service.NewCooperationProjectService(nil)
createCooperationProjectCommand := &command.CreateCooperationProjectCommand{}
err := controller.Unmarshal(createCooperationProjectCommand)
if err != nil {
log.Logger.Debug("json err:" + err.Error())
controller.Response(nil, err)
return
}
createCooperationProjectCommand.Operator = controller.GetOperator()
data, err := cooperationProjectService.CreateCooperationProject(createCooperationProjectCommand)
controller.Response(data, err)
}
func (controller *CooperationProjectController) UpdateCooperationProject() {
cooperationProjectService := service.NewCooperationProjectService(nil)
updateCooperationProjectCommand := &command.UpdateCooperationProjectCommand{}
err := controller.Unmarshal(updateCooperationProjectCommand)
if err != nil {
log.Logger.Debug("json err:" + err.Error())
controller.Response(nil, err)
return
}
projectId := controller.GetString(":projectId")
updateCooperationProjectCommand.CooperationProjectId = projectId
updateCooperationProjectCommand.Operator = controller.GetOperator()
data, err := cooperationProjectService.UpdateCooperationProject(updateCooperationProjectCommand)
controller.Response(data, err)
}
func (controller *CooperationProjectController) GetCooperationProject() {
cooperationProjectService := service.NewCooperationProjectService(nil)
getCooperationProjectQuery := &query.GetCooperationProjectQuery{}
projectId, _ := controller.GetInt(":projectId")
projectNumber := controller.GetString("cooperationProjectNumber")
orgId, _ := controller.GetInt("orgId")
getCooperationProjectQuery.CooperationProjectId = projectId
getCooperationProjectQuery.CooperationProjectNumber = projectNumber
getCooperationProjectQuery.OrgId = orgId
getCooperationProjectQuery.Operator = controller.GetOperator()
data, err := cooperationProjectService.GetCooperationProject(getCooperationProjectQuery)
controller.Response(data, err)
}
func (controller *CooperationProjectController) ListCooperationProject() {
cooperationProjectService := service.NewCooperationProjectService(nil)
listCooperationProjectQuery := &query.ListCooperationProjectQuery{}
err := controller.Unmarshal(listCooperationProjectQuery)
if err != nil {
log.Logger.Debug("json err:" + err.Error())
controller.Response(nil, err)
return
}
listCooperationProjectQuery.Operator = controller.GetOperator()
cnt, data, err := cooperationProjectService.ListCooperationProject(listCooperationProjectQuery)
controller.ReturnPageListData(cnt, data, err, listCooperationProjectQuery.PageNumber)
}
func (controller *CooperationProjectController) SelectorCooperationProject() {
cooperationProjectService := service.NewCooperationProjectService(nil)
listCooperationProjectQuery := &query.CooperationProjectSelectorQuery{}
err := controller.Unmarshal(listCooperationProjectQuery)
if err != nil {
log.Logger.Debug("json err:" + err.Error())
controller.Response(nil, err)
return
}
listCooperationProjectQuery.Operator = controller.GetOperator()
cnt, data, err := cooperationProjectService.ListCooperationProjectSelector(listCooperationProjectQuery)
controller.ReturnListData(cnt, data, err)
}
func (controller *CooperationProjectController) EndCooperationProject() {
cooperationProjectService := service.NewCooperationProjectService(nil)
endCooperationProjectCommand := &command.EndCooperationProjectCommand{}
err := controller.Unmarshal(endCooperationProjectCommand)
if err != nil {
log.Logger.Debug("json err:" + err.Error())
controller.Response(nil, err)
return
}
endCooperationProjectCommand.Operator = controller.GetOperator()
data, err := cooperationProjectService.EndCooperationProject(endCooperationProjectCommand)
controller.Response(data, err)
}