customize_menu.go
990 字节
package dto
import (
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/infrastructure/utils"
)
type CustomizeMenuDto struct {
}
func (dto *CustomizeMenuDto) LoadDto(menus []*domain.Menu, customizeMenus []*domain.CustomizeMenu) (interface{}, error) {
var ret []interface{}
menusMap := make(map[int64]*domain.Menu)
for i := range menus {
menusMap[menus[i].MenuId] = menus[i]
}
for i := range customizeMenus {
m := customizeMenus[i]
if menu, ok := menusMap[m.MenuId]; ok {
menu.MenuAlias = m.MenuAlias
}
}
for i := range menus {
fieldMenu := utils.LoadCustomFieldToMap(menus[i], "MenuId", "ParentId", "MenuName", "Code", "Icon", "MenuAlias", "MenuType", "Remark", "Sort", "EnableStatus")
fieldMenu["parentMenuName"] = ""
if menu, ok := menusMap[menus[i].ParentId]; ok {
fieldMenu["parentMenuName"] = menu.MenuName
}
ret = append(ret, fieldMenu)
}
return ret, nil
}