role_controller.go
6.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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
package controllers
import (
"github.com/linmadan/egglib-go/web/beego"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/application/role/command"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/application/role/query"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/application/role/service"
)
type RoleController struct {
beego.BaseController
}
func (controller *RoleController) CreateRole() {
roleService := service.NewRoleService(nil)
createRoleCommand := &command.CreateRoleCommand{}
Must(controller.Unmarshal(createRoleCommand))
createRoleCommand.OperateInfo = ParseOperateInfo(controller.BaseController)
data, err := roleService.CreateRole(createRoleCommand)
controller.Response(data, err)
}
func (controller *RoleController) UpdateRole() {
roleService := service.NewRoleService(nil)
updateRoleCommand := &command.UpdateRoleCommand{}
controller.Unmarshal(updateRoleCommand)
roleId, _ := controller.GetInt64(":roleId")
updateRoleCommand.RoleId = roleId
updateRoleCommand.OperateInfo = ParseOperateInfo(controller.BaseController)
data, err := roleService.UpdateRole(updateRoleCommand)
controller.Response(data, err)
}
func (controller *RoleController) GetRole() {
roleService := service.NewRoleService(nil)
getRoleQuery := &query.GetRoleQuery{}
roleId, _ := controller.GetInt64(":roleId")
getRoleQuery.RoleId = roleId
getRoleQuery.OperateInfo = ParseOperateInfo(controller.BaseController)
data, err := roleService.GetRole(getRoleQuery)
controller.Response(data, err)
}
func (controller *RoleController) RemoveRole() {
roleService := service.NewRoleService(nil)
removeRoleCommand := &command.RemoveRoleCommand{}
controller.Unmarshal(removeRoleCommand)
roleId, _ := controller.GetInt64(":roleId")
removeRoleCommand.RoleId = roleId
removeRoleCommand.OperateInfo = ParseOperateInfo(controller.BaseController)
data, err := roleService.RemoveRole(removeRoleCommand)
controller.Response(data, err)
}
func (controller *RoleController) BatchDeleteRole() {
roleService := service.NewRoleService(nil)
removeRoleCommand := &command.BatchDeleteRoleCommand{}
controller.Unmarshal(removeRoleCommand)
removeRoleCommand.OperateInfo = ParseOperateInfo(controller.BaseController)
data, err := roleService.BatchDeleteRole(removeRoleCommand)
controller.Response(data, err)
}
func (controller *RoleController) ListRole() {
roleService := service.NewRoleService(nil)
listRoleQuery := &query.ListRoleQuery{}
listRoleQuery.OperateInfo = ParseOperateInfo(controller.BaseController)
data, err := roleService.ListRole(listRoleQuery)
controller.Response(data, err)
}
func (controller *RoleController) SearchRole() {
roleService := service.NewRoleService(nil)
listRoleQuery := &query.ListRoleQuery{}
Must(controller.Unmarshal(listRoleQuery))
listRoleQuery.OperateInfo = ParseOperateInfo(controller.BaseController)
data, err := roleService.ListRole(listRoleQuery)
controller.Response(data, err)
}
func (controller *RoleController) GetRoleRelatedUsers() {
roleService := service.NewRoleService(nil)
getRoleRelatedUsersQuery := &query.GetRoleRelatedUsersQuery{}
roleId, _ := controller.GetInt64(":roleId")
getRoleRelatedUsersQuery.RoleId = roleId
orgId, _ := controller.GetInt64("orgId")
getRoleRelatedUsersQuery.OrgId = orgId
departmentId, _ := controller.GetInt64("departmentId")
getRoleRelatedUsersQuery.DepartmentId = departmentId
getRoleRelatedUsersQuery.OperateInfo = ParseOperateInfo(controller.BaseController)
data, err := roleService.GetRoleRelatedUsers(getRoleRelatedUsersQuery)
controller.Response(data, err)
}
func (controller *RoleController) RoleRelatedUsers() {
roleService := service.NewRoleService(nil)
getRoleRelatedUsersQuery := &query.GetRoleRelatedUsersQuery{}
controller.Unmarshal(getRoleRelatedUsersQuery)
roleId, _ := controller.GetInt64(":roleId")
getRoleRelatedUsersQuery.RoleId = roleId
getRoleRelatedUsersQuery.OperateInfo = ParseOperateInfo(controller.BaseController)
data, err := roleService.GetRoleRelatedUsers(getRoleRelatedUsersQuery)
controller.Response(data, err)
}
func (controller *RoleController) GetRoleAccessMenus() {
roleService := service.NewRoleService(nil)
getRoleAccessMenusQuery := &query.GetRoleAccessMenusQuery{}
roleId, _ := controller.GetInt64(":roleId")
getRoleAccessMenusQuery.RoleId = roleId
getRoleAccessMenusQuery.OperateInfo = ParseOperateInfo(controller.BaseController)
data, err := roleService.GetRoleAccessMenus(getRoleAccessMenusQuery)
controller.Response(data, err)
}
func (controller *RoleController) UpdateRoleAccessMenus() {
roleService := service.NewRoleService(nil)
updateRoleAccessMenusCommand := &command.UpdateRoleAccessMenusCommand{}
controller.Unmarshal(updateRoleAccessMenusCommand)
roleId, _ := controller.GetInt64(":roleId")
updateRoleAccessMenusCommand.RoleId = roleId
updateRoleAccessMenusCommand.OperateInfo = ParseOperateInfo(controller.BaseController)
data, err := roleService.UpdateRoleAccessMenus(updateRoleAccessMenusCommand)
controller.Response(data, err)
}
func (controller *RoleController) AssginRoleToUsers() {
roleService := service.NewRoleService(nil)
assginRoleToUsersCommand := &command.AssginRoleToUsersCommand{}
controller.Unmarshal(assginRoleToUsersCommand)
assginRoleToUsersCommand.OperateInfo = ParseOperateInfo(controller.BaseController)
data, err := roleService.AssginRoleToUsers(assginRoleToUsersCommand)
controller.Response(data, err)
}
func (controller *RoleController) UnAssginRoleToUsers() {
roleService := service.NewRoleService(nil)
unAssginRoleToUsersCommand := &command.UnAssginRoleToUsersCommand{}
controller.Unmarshal(unAssginRoleToUsersCommand)
unAssginRoleToUsersCommand.OperateInfo = ParseOperateInfo(controller.BaseController)
data, err := roleService.UnAssginRoleToUsers(unAssginRoleToUsersCommand)
controller.Response(data, err)
}
/***** 1.适配web模块 *****/
func (controller *RoleController) WebSearchRole() {
roleService := service.NewRoleService(nil)
listRoleQuery := &query.ListRoleQuery{}
Must(controller.Unmarshal(listRoleQuery))
listRoleQuery.Limit = 20
listRoleQuery.CompanyId = 23
data, err := roleService.ListRole(listRoleQuery)
webData := map[string]interface{}{
"list": data.(map[string]interface{})["roles"],
"total": data.(map[string]interface{})["count"],
}
ResponseGrid(controller.BaseController, webData, err)
}