学成在线第3天讲义-CMS页面管理开发1自定义条件查询1.1需求分析在页面输入查询条件,查询符合条件的页面信息。查询条件如下:站点Id:精确匹配模板Id:精确匹配页面别名:模糊匹配...1.2服务端1.2.1Dao下边测试findAll方法实现自定义条件查询:使用CmsPageRepository中的findAll(Examplevar1,Pageablevar2)方法实现,无需定义。//自定义条件查询测试@TestpublicvoidtestFindAll(){//条件匹配器ExampleMatcherexampleMatcher=ExampleMatcher.matching();exampleMatcher=exampleMatcher.withMatcher("pageAliase",ExampleMatcher.GenericPropertyMatchers.contains());//页面别名模糊查询,需要自定义字符串的匹配器实现模糊查询//ExampleMatcher.GenericPropertyMatchers.contains()包含//ExampleMatcher.GenericPropertyMatchers.startsWith()//开头匹配//条件值CmsPagecmsPage=newCmsPage();//站点IDcmsPage.setSiteId("5a751fab6abb5044e0d19ea1");//模板IDcmsPage.setTemplateId("5a962c16b00ffc514038fafd");//cmsPage.setPageAliase("分类导航");//创建条件实例Exampleexample=Example.of(cmsPage,exampleMatcher);北京市昌平区建材城西路金燕龙办公楼一层电话:400-618-90901.2.2Service在PageService的findlist方法中增加自定义条件查询代码1.2.3ControllerPageablepageable=newPageRequest(0,10);Pageall=cmsPageRepository.findAll(example,pageable);System.out.println(all);}/***页面列表分页查询*@parampage当前页码*@paramsize页面显示个数*@paramqueryPageRequest查询条件*@return页面列表*/publicQueryResponseResultfindList(intpage,intsize,QueryPageRequestqueryPageRequest){//条件匹配器//页面名称模糊查询,需要自定义字符串的匹配器实现模糊查询ExampleMatcherexampleMatcher=ExampleMatcher.matching().withMatcher("pageAliase",ExampleMatcher.GenericPropertyMatchers.contains());//条件值CmsPagecmsPage=newCmsPage();//站点IDif(StringUtils.isNotEmpty(queryPageRequest.getSiteId())){cmsPage.setSiteId(queryPageRequest.getSiteId());}//页面别名if(StringUtils.isNotEmpty(queryPageRequest.getPageAliase())){cmsPage.setPageAliase(queryPageRequest.getPageAliase());}//创建条件实例Exampleexample=Example.of(cmsPage,exampleMatcher);//页码page=page‐1;//分页对象Pagea...