orgs_controller.go
3.2 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
package web_client
import (
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/orgs/command"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/orgs/query"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/orgs/service"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/log"
)
type OrgsController struct {
baseController
}
func (controller *OrgsController) OrgAdd() {
orgsService := service.NewOrgsService(nil)
orgAddCommand := &command.OrgAddCommand{}
err := controller.Unmarshal(orgAddCommand)
if err != nil {
log.Logger.Debug("json err:" + err.Error())
}
orgAddCommand.Operator = controller.GetOperator()
data, err := orgsService.OrgAdd(orgAddCommand)
controller.Response(data, err)
}
func (controller *OrgsController) OrgUpdate() {
orgsService := service.NewOrgsService(nil)
orgUpdateCommand := &command.OrgUpdateCommand{}
err := controller.Unmarshal(orgUpdateCommand)
if err != nil {
log.Logger.Debug("json err:" + err.Error())
}
orgId := controller.GetString(":orgId")
orgUpdateCommand.OrgId = orgId
orgUpdateCommand.Operator = controller.GetOperator()
data, err := orgsService.OrgUpdate(orgUpdateCommand)
controller.Response(data, err)
}
func (controller *OrgsController) OrgList() {
orgsService := service.NewOrgsService(nil)
orgListQuery := &query.OrgListQuery{}
err := controller.Unmarshal(orgListQuery)
if err != nil {
log.Logger.Debug("json err:" + err.Error())
}
orgListQuery.Operator = controller.GetOperator()
data, err := orgsService.OrgList(orgListQuery)
controller.Response(data, err)
}
func (controller *OrgsController) OrgGet() {
orgsService := service.NewOrgsService(nil)
orgGetQuery := &query.OrgGetQuery{}
orgId := controller.GetString(":orgId")
orgGetQuery.OrgId = orgId
orgGetQuery.Operator = controller.GetOperator()
data, err := orgsService.OrgGet(orgGetQuery)
controller.Response(data, err)
}
func (controller *OrgsController) OrgEnable() {
orgsService := service.NewOrgsService(nil)
orgEnableCommand := &command.OrgEnableCommand{}
err := controller.Unmarshal(orgEnableCommand)
if err != nil {
log.Logger.Debug("json err:" + err.Error())
}
orgEnableCommand.Operator = controller.GetOperator()
data, err := orgsService.OrgEnable(orgEnableCommand)
controller.Response(data, err)
}
func (controller *OrgsController) OrgGetSubDepartment() {
orgsService := service.NewOrgsService(nil)
orgGetSubDepartmentQuery := &query.OrgGetSubDepartmentQuery{}
err := controller.Unmarshal(orgGetSubDepartmentQuery)
if err != nil {
log.Logger.Debug("json err:" + err.Error())
}
orgGetSubDepartmentQuery.Operator = controller.GetOperator()
data, err := orgsService.OrgGetSubDepartment(orgGetSubDepartmentQuery)
controller.Response(data, err)
}
func (controller *OrgsController) DepartmentUsers() {
orgService := service.OrgsService{}
departmentsUsersQuery := &query.DepartmentsUsersQuery{}
err := controller.Unmarshal(departmentsUsersQuery)
if err != nil {
controller.Response(nil, err)
return
}
departmentsUsersQuery.Operator = controller.GetOperator()
data, err := orgService.DepartmentsUsers(departmentsUsersQuery)
controller.Response(data, err)
}