role_controller.go
4.1 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 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))
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
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
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
data, err := roleService.RemoveRole(removeRoleCommand)
controller.Response(data, err)
}
func (controller *RoleController) ListRole() {
roleService := service.NewRoleService(nil)
listRoleQuery := &query.ListRoleQuery{}
data, err := roleService.ListRole(listRoleQuery)
controller.Response(data, err)
}
func (controller *RoleController) SearchRole() {
roleService := service.NewRoleService(nil)
listRoleQuery := &query.ListRoleQuery{}
Must(controller.Unmarshal(listRoleQuery))
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
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
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
data, err := roleService.UpdateRoleAccessMenus(updateRoleAccessMenusCommand)
controller.Response(data, err)
}
func (controller *RoleController) AssginRoleToUsers() {
roleService := service.NewRoleService(nil)
assginRoleToUsersCommand := &command.AssginRoleToUsersCommand{}
controller.Unmarshal(assginRoleToUsersCommand)
data, err := roleService.AssginRoleToUsers(assginRoleToUsersCommand)
controller.Response(data, err)
}
func (controller *RoleController) UnAssginRoleToUsers() {
roleService := service.NewRoleService(nil)
unAssginRoleToUsersCommand := &command.UnAssginRoleToUsersCommand{}
controller.Unmarshal(unAssginRoleToUsersCommand)
data, err := roleService.UnAssginRoleToUsers(unAssginRoleToUsersCommand)
controller.Response(data, err)
}