输入banner图图片脚本导航/分类

springboot jpa mongodb 多条件分页查询

id =XX

        Criteria criteria = Criteria.where("callerId").is(recorded.getCallerId());

criteria.and(“status”).is(Recorded.SUCCESS);

if(startTime!=null&&endTime!=null){

            criteria.andOperator(

                    Criteria.where("createTime").gte(startTime),

                    Criteria.where("createTime").lte(endTime)

            );

        }

query.addCriteria(criteria);

 

        //mongoTemplate.count计算总数

        long total = mongoTemplate.count(query, Recorded.class);

        

        // mongoTemplate.find 查询结果集

        List<Recorded> items = mongoTemplate.find(query.with(pageable), Recorded.class);

 

        return new PageImpl(items, pageable, total);

 

    }

springboot jpa mongodb 多条件分页查询

标签:status   pos   count   tar   stat   list   operator   opera   create