Public page<recorded> getrecordeds (integer Page, integer size, Recorded Recorded) {
if (page<1) {
page=1;
}
Sort sort = new sort (Sort.Direction.DESC, "createtime");
pageable pageable = new Pagerequest (page-1,size,sort);
Query query = new query ();
condition ID =xx
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 Total Calculation
Long total = mongotemplate.count (query, Recorded.class);
Mongotemplate.find Query Result set
list<recorded> items = Mongotemplate.find (Query.with (pageable), recorded.class);
return new Pageimpl (items, pageable, total);
}
Springboot JPA MongoDB Multi-Conditional paging query