package com.qianwen.smartman.modules.system.wrapper;
|
|
import java.util.List;
|
import java.util.Objects;
|
import java.util.stream.Collectors;
|
import com.qianwen.smartman.common.cache.DictCache;
|
import com.qianwen.smartman.common.cache.SysCache;
|
import com.qianwen.smartman.common.enums.DictEnum;
|
import com.qianwen.core.mp.support.BaseEntityWrapper;
|
import com.qianwen.core.tool.constant.BladeConstant;
|
import com.qianwen.core.tool.node.ForestNodeMerger;
|
import com.qianwen.core.tool.utils.BeanUtil;
|
import com.qianwen.core.tool.utils.Func;
|
import com.qianwen.smartman.modules.system.entity.Menu;
|
import com.qianwen.smartman.modules.system.vo.MenuVO;
|
|
/* loaded from: blade-api.jar:BOOT-INF/classes/org/springblade/modules/system/wrapper/MenuWrapper.class */
|
public class MenuWrapper extends BaseEntityWrapper<Menu, MenuVO> {
|
public static MenuWrapper build() {
|
return new MenuWrapper();
|
}
|
|
public MenuVO entityVO(Menu menu) {
|
MenuVO menuVO = (MenuVO) Objects.requireNonNull(BeanUtil.copy(menu, MenuVO.class));
|
if (Func.equals(menu.getParentId(), BladeConstant.TOP_PARENT_ID)) {
|
menuVO.setParentName("顶级");
|
} else {
|
Menu parent = SysCache.getMenu(menu.getParentId());
|
menuVO.setParentName(parent.getName());
|
}
|
String category = DictCache.getValue(DictEnum.MENU_CATEGORY, Integer.valueOf(Func.toInt(menuVO.getCategory())));
|
String action = DictCache.getValue(DictEnum.BUTTON_FUNC, Integer.valueOf(Func.toInt(menuVO.getAction())));
|
String open = DictCache.getValue(DictEnum.YES_NO, Integer.valueOf(Func.toInt(menuVO.getIsOpen())));
|
menuVO.setCategoryName(category);
|
menuVO.setActionName(action);
|
menuVO.setIsOpenName(open);
|
return menuVO;
|
}
|
|
public List<MenuVO> listNodeVO(List<Menu> list) {
|
List<MenuVO> collect = (List) list.stream().map(menu -> {
|
return (MenuVO) BeanUtil.copy(menu, MenuVO.class);
|
}).collect(Collectors.toList());
|
return ForestNodeMerger.merge(collect);
|
}
|
|
public List<MenuVO> listNodeLazyVO(List<MenuVO> list) {
|
return ForestNodeMerger.merge(list);
|
}
|
}
|