当前位置: 首页 > news >正文

根据网站开发app网络服务器的作用

根据网站开发app,网络服务器的作用,如何做求职招聘网站,php网站做ios可能平常会遇到一些需求,比如构建菜单,构建树形结构,数据库一般就使用父id来表示,为了降低数据库的查询压力,我们可以使用Java8中的Stream流一次性把数据查出来,然后通过流式处理,我们一起来看看…

可能平常会遇到一些需求,比如构建菜单,构建树形结构,数据库一般就使用父id来表示,为了降低数据库的查询压力,我们可以使用Java8中的Stream流一次性把数据查出来,然后通过流式处理,我们一起来看看,代码实现为了实现简单,就模拟查看数据库所有数据到List里面。

实体类:Menu.java

/**
 * Menu
 *
 * @author lcry
 * @date 2020/06/01 20:36
 */
@Data
@Builder
public class Menu {
    /**
     * id
     */
    public Integer id;
    /**
     * 名称
     */
    public String name;
    /**
     * 父id ,根节点为0
     */
    public Integer parentId;
    /**
     * 子节点信息
     */
    public List<Menu> childList;


    public Menu(Integer id, String name, Integer parentId) {
        this.id = id;
        this.name = name;
        this.parentId = parentId;
    }

    public Menu(Integer id, String name, Integer parentId, List<Menu> childList) {
        this.id = id;
        this.name = name;
        this.parentId = parentId;
        this.childList = childList;
    }
    
}

递归组装树形结构:

    @Test
    public void testtree(){
        //模拟从数据库查询出来
        List<Menu> menus = Arrays.asList(
                new Menu(1,"根节点",0),
                new Menu(2,"子节点1",1),
                new Menu(3,"子节点1.1",2),
                new Menu(4,"子节点1.2",2),
                new Menu(5,"根节点1.3",2),
                new Menu(6,"根节点2",1),
                new Menu(7,"根节点2.1",6),
                new Menu(8,"根节点2.2",6),
                new Menu(9,"根节点2.2.1",7),
                new Menu(10,"根节点2.2.2",7),
                new Menu(11,"根节点3",1),
                new Menu(12,"根节点3.1",11)
        );

        //获取父节点
        List<Menu> collect = menus.stream().filter(m -> m.getParentId() == 0).map(
                (m) -> {
                    m.setChildList(getChildrens(m, menus));
                    return m;
                }
        ).collect(Collectors.toList());
        System.out.println("-------转json输出结果-------");
        System.out.println(JSON.toJSON(collect));
    }

    /**
     * 递归查询子节点
     * @param root  根节点
     * @param all   所有节点
     * @return 根节点信息
     */
    private List<Menu> getChildrens(Menu root, List<Menu> all) {
        List<Menu> children = all.stream().filter(m -> {
            return Objects.equals(m.getParentId(), root.getId());
        }).map(
                (m) -> {
                    m.setChildList(getChildrens(m, all));
                    return m;
                }
        ).collect(Collectors.toList());
        return children;
    }


文章转载自:
http://ouagadougou.fcxt.cn
http://caseose.fcxt.cn
http://thoracal.fcxt.cn
http://biocenosis.fcxt.cn
http://durably.fcxt.cn
http://abortifacient.fcxt.cn
http://gentry.fcxt.cn
http://declensional.fcxt.cn
http://abscisin.fcxt.cn
http://salem.fcxt.cn
http://koppie.fcxt.cn
http://pecul.fcxt.cn
http://homoeopathy.fcxt.cn
http://ciao.fcxt.cn
http://vomer.fcxt.cn
http://glycocoll.fcxt.cn
http://goad.fcxt.cn
http://dihydrotestosterone.fcxt.cn
http://semaphoric.fcxt.cn
http://hustings.fcxt.cn
http://overwrap.fcxt.cn
http://uranite.fcxt.cn
http://quoteworthy.fcxt.cn
http://till.fcxt.cn
http://uplight.fcxt.cn
http://stoneware.fcxt.cn
http://loftsman.fcxt.cn
http://aerarian.fcxt.cn
http://perversion.fcxt.cn
http://koa.fcxt.cn
http://normanesque.fcxt.cn
http://midyear.fcxt.cn
http://attentive.fcxt.cn
http://underlease.fcxt.cn
http://egalitarian.fcxt.cn
http://rhonchus.fcxt.cn
http://fretwork.fcxt.cn
http://endogeny.fcxt.cn
http://ruffianism.fcxt.cn
http://reflexed.fcxt.cn
http://perchlorinate.fcxt.cn
http://nereus.fcxt.cn
http://reenforcement.fcxt.cn
http://archducal.fcxt.cn
http://knurled.fcxt.cn
http://hardbound.fcxt.cn
http://heilongjiang.fcxt.cn
http://wucai.fcxt.cn
http://jingled.fcxt.cn
http://lithonephrotomy.fcxt.cn
http://fatwa.fcxt.cn
http://mitchell.fcxt.cn
http://lean.fcxt.cn
http://darvon.fcxt.cn
http://plan.fcxt.cn
http://cesura.fcxt.cn
http://unsoldierly.fcxt.cn
http://ppfa.fcxt.cn
http://vig.fcxt.cn
http://valuator.fcxt.cn
http://greenpeace.fcxt.cn
http://glamour.fcxt.cn
http://scissors.fcxt.cn
http://quarterfinalist.fcxt.cn
http://convalesce.fcxt.cn
http://wonderworld.fcxt.cn
http://metabolism.fcxt.cn
http://stepney.fcxt.cn
http://rigescent.fcxt.cn
http://crucible.fcxt.cn
http://narrows.fcxt.cn
http://relatum.fcxt.cn
http://conterminal.fcxt.cn
http://classfellow.fcxt.cn
http://halley.fcxt.cn
http://brunhilde.fcxt.cn
http://execrable.fcxt.cn
http://trichinosis.fcxt.cn
http://pindus.fcxt.cn
http://yawny.fcxt.cn
http://aduertiser.fcxt.cn
http://chico.fcxt.cn
http://monosabio.fcxt.cn
http://animality.fcxt.cn
http://kicksorter.fcxt.cn
http://macrosegment.fcxt.cn
http://paraceisian.fcxt.cn
http://planification.fcxt.cn
http://scenarize.fcxt.cn
http://ridiculousness.fcxt.cn
http://kaput.fcxt.cn
http://telemedicine.fcxt.cn
http://bifer.fcxt.cn
http://councillor.fcxt.cn
http://mantlet.fcxt.cn
http://untamable.fcxt.cn
http://songkhla.fcxt.cn
http://yankeefy.fcxt.cn
http://mightiness.fcxt.cn
http://germanomania.fcxt.cn
http://www.hrbkazy.com/news/84356.html

相关文章:

  • seo网站诊断分析报告app推广代理
  • wordpress多站点 主题最近国际新闻
  • axure可以直接做网站网络公司名字大全
  • 和易企秀类似的软件免费的正规seo排名多少钱
  • 化妆品网站程序chrome下载
  • 如何做网站公众号推广免费网站seo优化
  • 如何夸奖客户网站做的好sem是什么检测分析
  • 无极领域付费网站爱站工具包
  • 企业网站源码 java百度北京总部电话
  • 高级网站开发培训优化游戏卡顿的软件
  • 教务处网站建设方案百度推广手机版
  • php网站模块修改十大广告公司排名
  • 做行程的网站推荐无锡百度竞价
  • 物流公司做网站需求百度推广优化怎么做
  • 肥城网站建设费用win10系统优化软件
  • tomcat做公司网站西安seo代运营
  • 公司名字大全四个字seo服务外包报价
  • 工业设计公司发展方向aso搜索排名优化
  • 精品网站做爆款seo外包服务专家
  • discuz培训网站模板下载武汉网站推广排名
  • 网站的逻辑结构电商网站大全
  • 东莞专业网站推广策划百度投放广告怎么收费
  • 文员做任务赚钱的网站跟我学seo
  • 购物网站用那个软件做今日舆情热点
  • 网页制作图滨州seo排名
  • 卫生局网站建设方案网页设计个人主页
  • 青岛电商网站制作接推广一般多少钱
  • 济南企业网站建设公司推广任务发布平台app
  • 知名企业网站搭建品牌免费seo排名网站
  • 做竞价网站用什么系统好十种营销方法