menu_controller.go
3.5 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 backgroud_client
import (
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/background/menu/command"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/background/menu/query"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/background/menu/service"
)
type MenuController struct {
baseController
}
func (controller *MenuController) CreateMenu() {
menuService := service.NewMenuService(nil)
createMenuCommand := &command.CreateMenuCommand{}
controller.Unmarshal(createMenuCommand)
createMenuCommand.Operator = controller.GetOperator()
data, err := menuService.CreateMenu(createMenuCommand)
controller.Response(data, err)
}
func (controller *MenuController) UpdateMenu() {
menuService := service.NewMenuService(nil)
updateMenuCommand := &command.UpdateMenuCommand{}
controller.Unmarshal(updateMenuCommand)
Id, _ := controller.GetInt64(":menuId")
updateMenuCommand.MenuId = Id
updateMenuCommand.Operator = controller.GetOperator()
data, err := menuService.UpdateMenu(updateMenuCommand)
controller.Response(data, err)
}
func (controller *MenuController) GetMenu() {
menuService := service.NewMenuService(nil)
getMenuQuery := &query.GetMenuQuery{}
Id, _ := controller.GetInt64(":menuId")
getMenuQuery.MenuId = Id
getMenuQuery.Operator = controller.GetOperator()
data, err := menuService.GetMenu(getMenuQuery)
controller.Response(data, err)
}
func (controller *MenuController) RemoveMenu() {
menuService := service.NewMenuService(nil)
removeMenuCommand := &command.RemoveMenuCommand{}
controller.Unmarshal(removeMenuCommand)
Id, _ := controller.GetInt64(":menuId")
removeMenuCommand.MenuId = Id
removeMenuCommand.Operator = controller.GetOperator()
data, err := menuService.RemoveMenu(removeMenuCommand)
controller.Response(data, err)
}
func (controller *MenuController) ListMenu() {
menuService := service.NewMenuService(nil)
listMenuQuery := &query.ListMenuQuery{}
offset, _ := controller.GetInt("offset")
listMenuQuery.Offset = offset
limit, _ := controller.GetInt("limit")
listMenuQuery.Limit = limit
listMenuQuery.MenuCategory = controller.GetString("menuCategory")
listMenuQuery.ParentId, _ = controller.GetInt64("parentId", 0)
listMenuQuery.MenuName = controller.GetString("menuName")
listMenuQuery.StructType = controller.GetString("structType")
listMenuQuery.Operator = controller.GetOperator()
data, err := menuService.ListMenu(listMenuQuery)
controller.Response(data, err)
}
func (controller *MenuController) SearchMenu() {
menuService := service.NewMenuService(nil)
listMenuQuery := &query.ListMenuQuery{}
controller.Unmarshal(listMenuQuery)
listMenuQuery.Offset = 0
listMenuQuery.Limit = 0
listMenuQuery.Operator = controller.GetOperator()
data, err := menuService.ListMenu(listMenuQuery)
controller.Response(data, err)
}
func (controller *MenuController) BatchDeleteMenu() {
menuService := service.NewMenuService(nil)
batchDeleteMenuCommand := &command.BatchDeleteMenuCommand{}
controller.Unmarshal(batchDeleteMenuCommand)
batchDeleteMenuCommand.Operator = controller.GetOperator()
data, err := menuService.BatchDeleteMenu(batchDeleteMenuCommand)
controller.Response(data, err)
}
func (controller *MenuController) BatchEnableMenu() {
menuService := service.NewMenuService(nil)
batchEnableMenu := &command.BatchEnableMenuCommand{}
controller.Unmarshal(batchEnableMenu)
batchEnableMenu.Operator = controller.GetOperator()
data, err := menuService.BatchEnableMenu(batchEnableMenu)
controller.Response(data, err)
}