menu.go
2.6 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
package service
import (
"github.com/linmadan/egglib-go/core/application"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/custommenu/command"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/custommenu/query"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_user"
)
// 用户菜单维护
type MenuService struct {
}
// 设置收藏菜单
func (menuService *MenuService) MenuFavorite(menuFavoriteCommand *command.MenuFavoriteCommand) (interface{}, error) {
creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(
menuFavoriteCommand.Operator.CompanyId,
menuFavoriteCommand.Operator.OrgId,
menuFavoriteCommand.Operator.UserId)
result, err := creationUserGateway.CompanyGetCustomizeMenus(allied_creation_user.ReqCompanyGetCustomizeMenus{
CompanyId: menuFavoriteCommand.Operator.CompanyId,
})
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return result, nil
}
// 返回菜单列表
func (menuService *MenuService) MenuList(menuListQuery *query.MenuListQuery) (interface{}, error) {
creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(
menuListQuery.Operator.CompanyId,
menuListQuery.Operator.OrgId,
menuListQuery.Operator.UserId)
result, err := creationUserGateway.CompanyGetCustomizeMenus(allied_creation_user.ReqCompanyGetCustomizeMenus{
CompanyId: menuListQuery.Operator.CompanyId,
MenuCategory: menuListQuery.MenuCategory,
})
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return map[string]interface{}{
"menus": result.Menus,
}, nil
}
// 更新菜单
func (menuService *MenuService) MenuUpdate(menuUpdateCommand *command.MenuUpdateCommand) (interface{}, error) {
creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(
menuUpdateCommand.Operator.CompanyId,
menuUpdateCommand.Operator.OrgId,
menuUpdateCommand.Operator.UserId)
_, err := creationUserGateway.CompanySetCustomizeMenus(allied_creation_user.ReqCompanySetCustomizeMenus{
CompanyId: menuUpdateCommand.Operator.CompanyId,
MenuAlias: menuUpdateCommand.MenuAlias,
MenuId: int(menuUpdateCommand.MenuId),
Sort: menuUpdateCommand.Sort,
})
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return menuUpdateCommand, nil
}
func NewMenuService(options map[string]interface{}) *MenuService {
newMenuService := &MenuService{}
return newMenuService
}