mongoRepositoy

    技术2022-07-13  69

    TranStringMGDO entity=new TranStringMGDO(); entity.setProjectId(vo.getProjectId()); if(StringUtils.isNotEmpty(vo.getOriginString())){ entity.setOriginString(vo.getOriginString()); } if(Objects.nonNull(vo.getFileId())){ entity.setFileId(vo.getFileId()); } Sort sort = new Sort(Sort.Direction.DESC, "createTime"); PageRequest pageRequest = PageRequest.of(vo.getPageIndex()-1, vo.getPageSize(), sort); ExampleMatcher matcher = ExampleMatcher.matching() .withStringMatcher(ExampleMatcher.StringMatcher.CONTAINING) //改变默认字符串匹配方式:模糊查询 .withIgnoreCase(true) //改变默认大小写忽略方式:忽略大小写 .withMatcher("originString", ExampleMatcher.GenericPropertyMatchers.contains()) //采用“包含匹配”的方式查询 .withIgnorePaths("pageIndex", "pageSize"); //忽略属性,不参与查询; Example<TranStringMGDO> example = Example.of(entity, matcher); Page<TranStringMGDO> all = tranStringMGRepository.findAll(example, pageRequest); long total = all.getTotalElements(); List<TranStringMGDO> rows = all.getContent(); DataGridResultDTO<TranStringMGDO> result=new DataGridResultDTO<>(); result.setRows(rows); result.setTotal(total);

     

    Processed: 0.011, SQL: 9