org_controller.go
3.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
package controllers
import (
"github.com/linmadan/egglib-go/web/beego"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/application/org/command"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/application/org/query"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/application/org/service"
)
type OrgController struct {
beego.BaseController
}
func (controller *OrgController) CreateOrg() {
orgService := service.NewOrgService(nil)
createOrgCommand := &command.CreateOrgCommand{}
controller.Unmarshal(createOrgCommand)
createOrgCommand.OperateInfo = ParseOperateInfo(controller.BaseController)
data, err := orgService.CreateOrg(createOrgCommand)
controller.Response(data, err)
}
func (controller *OrgController) UpdateOrg() {
orgService := service.NewOrgService(nil)
updateOrgCommand := &command.UpdateOrgCommand{}
controller.Unmarshal(updateOrgCommand)
orgId, _ := controller.GetInt64(":orgId")
updateOrgCommand.OrgId = orgId
updateOrgCommand.OperateInfo = ParseOperateInfo(controller.BaseController)
data, err := orgService.UpdateOrg(updateOrgCommand)
controller.Response(data, err)
}
func (controller *OrgController) GetOrg() {
orgService := service.NewOrgService(nil)
getOrgQuery := &query.GetOrgQuery{}
orgId, _ := controller.GetInt64(":orgId")
getOrgQuery.OrgId = orgId
getOrgQuery.OperateInfo = ParseOperateInfo(controller.BaseController)
data, err := orgService.GetOrg(getOrgQuery)
controller.Response(data, err)
}
func (controller *OrgController) RemoveOrg() {
orgService := service.NewOrgService(nil)
removeOrgCommand := &command.RemoveOrgCommand{}
controller.Unmarshal(removeOrgCommand)
orgId, _ := controller.GetInt64(":orgId")
removeOrgCommand.OrgId = orgId
removeOrgCommand.OperateInfo = ParseOperateInfo(controller.BaseController)
data, err := orgService.RemoveOrg(removeOrgCommand)
controller.Response(data, err)
}
func (controller *OrgController) ListOrg() {
orgService := service.NewOrgService(nil)
listOrgQuery := &query.ListOrgQuery{}
listOrgQuery.OperateInfo = ParseOperateInfo(controller.BaseController)
data, err := orgService.ListOrg(listOrgQuery)
controller.Response(data, err)
}
func (controller *OrgController) GetOrgSubDepartment() {
orgService := service.NewOrgService(nil)
getOrgSubDepartmentQuery := &query.GetOrgSubDepartmentQuery{}
orgId, _ := controller.GetInt64(":orgId")
getOrgSubDepartmentQuery.OrgId = orgId
childFlag, _ := controller.GetInt("childFlag")
getOrgSubDepartmentQuery.ChildFlag = childFlag
getOrgSubDepartmentQuery.OperateInfo = ParseOperateInfo(controller.BaseController)
data, err := orgService.GetOrgSubDepartment(getOrgSubDepartmentQuery)
controller.Response(data, err)
}
func (controller *OrgController) EnableOrg() {
orgService := service.NewOrgService(nil)
enableOrgCommand := &command.EnableOrgCommand{}
controller.Unmarshal(enableOrgCommand)
enableOrgCommand.OperateInfo = ParseOperateInfo(controller.BaseController)
data, err := orgService.EnableOrg(enableOrgCommand)
controller.Response(data, err)
}
func (controller *OrgController) SearchOrg() {
orgService := service.NewOrgService(nil)
listOrgQuery := &query.ListOrgQuery{}
Must(controller.Unmarshal(listOrgQuery))
listOrgQuery.OperateInfo = ParseOperateInfo(controller.BaseController)
data, err := orgService.ListOrg(listOrgQuery)
controller.Response(data, err)
}