🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
``` /** * @author 张跃帅 * @Description: 系统首页-工具 * @date 2020/08/12 */ public class SystemHomeUtil { private static final SystemHomeService systemHomeService = SpringUtil.getBean(SystemHomeService.class); /** * 获取-默认首页-菜单 */ public static SystemHomeEntity getDefHome() { // 获取参数 String appCode = SystemContext.me().getAppCode(); // 创建查询包装器 LambdaQueryWrapper<SystemHomeEntity> queryWrapper = new LambdaQueryWrapper<>(); // 设置条件 queryWrapper.eq(SystemHomeEntity::getAppCode, appCode) .eq(SystemHomeEntity::getDefHome, CommonYesOrNotEnum.YES.getCode()) .eq(SystemHomeEntity::getDataFlag, CommonDataFlagEnum.NORMAL.getCode()) .eq(SystemHomeEntity::getDelFlag, CommonDelFlagEnum.NOT_DELETE.getCode()); // 返回 return systemHomeService.getOne(queryWrapper); } /** * 获取-首页List */ public static List<SystemHomeEntity> getList() { // 获取参数 String appCode = SystemContext.me().getAppCode(); // 创建查询包装器 LambdaQueryWrapper<SystemHomeEntity> queryWrapper = new LambdaQueryWrapper<>(); // 设置条件 queryWrapper.eq(SystemHomeEntity::getAppCode, appCode) .eq(SystemHomeEntity::getDataFlag, CommonDataFlagEnum.NORMAL.getCode()) .eq(SystemHomeEntity::getDelFlag, CommonDelFlagEnum.NOT_DELETE.getCode()); // 返回 return systemHomeService.list(queryWrapper); } /** * 获取-首页tree树 */ public static List<Tree<String>> getTree() { // 变量创建ArrayList List<Tree<String>> treeNodeList = CollectionUtil.newArrayList(); // 查询 List<SystemHomeEntity> systemHomeList = SystemHomeUtil.getList(); // 判断 if (systemHomeList != null && systemHomeList.size() > 0) { // 获取参数 String parentId = CommonTreeParentIdEnum.PARENTID_0.getCode(); // tree转换器 treeNodeList = TreeUtil.build(systemHomeList, parentId, (systemHome, tree) -> { // 赋值 tree.setId(Convert.toStr(systemHome.getId())); tree.setParentId(parentId); tree.setName(systemHome.getHomeName()); }); } // 返回 return treeNodeList; } }