(1)controller
@RequestMapping("/findData")
@ResponseBody
public Object findPhoneList(String startDate,String endDate,String phone,Integer pageIndex,Integer rows){
System.out.println(startDate+"||"+endDate+"||"+phone+"||"+pageIndex+"||"+rows);
PageInfo phoneList = cdrVoiceService.findPhoneListService(startDate, endDate, phone, pageIndex, rows);
return phoneList;
}
(2)service
public PageInfo findPhoneListService(String startDate,String endDate,String phone,Integer pageIndex,Integer rows){
Integer min = (pageIndex - 1) * rows;
Integer max = pageIndex * rows;
startDate=startDate!=""&&startDate!=null ?startDate+" 00:00:00":startDate;
endDate=endDate!=""&&endDate!=null?endDate+" 23:59:59":endDate;
int count = fraudCdrDao.countData(startDate, endDate, phone);
List phoneInfos=new ArrayList<>();
if(count>0){
phoneInfos = fraudCdrDao.listData(startDate, endDate, phone, max, min);
}
PageInfo pageInfo = new PageInfo();
pageInfo.setRows(phoneInfos);
pageInfo.setTotal(count);
return pageInfo;
}
(3)dao
@Select("
" select count(*) from phoneTable t " +
" "+
" " +
" and t.phone like '%${phone}%'" +
" " +
" " +
" and t.insert_time >= to_date('${startDate}','yyyy-mm-dd hh24:mi:ss') " +
" " +
" " +
" and t.insert_time <= to_date('${endDate}','yyyy-mm-dd hh24:mi:ss') " +
" " +
" " +
" ")
int countData(@Param("startDate") String startDate,@Param("endDate") String endDate,@Param("phone") String phone);
@Select("
" select t2.id,t2.phone,trim(t2.phone_type) phone_type,to_char(t2.insert_time,'yyyy-mm-dd hh24:mi:ss') insert_time,t2.insert_user from (" +
" select t.*,ROWNUM rn from phoneTable t " +
" " +
" " +
" and ROWNUM <= ${max}" +
" "+
" " +
" and t.phone like '%${phone}%'" +
" " +
" " +
" and t.insert_time >= to_date('${startDate}','yyyy-mm-dd hh24:mi:ss') " +
" " +
" " +
" and t.insert_time <= to_date('${endDate}','yyyy-mm-dd hh24:mi:ss') " +
" " +
" )t2 " +
" " +
" " +
" t2.rn > ${min}" +
" " +
" " +
" order by t2.insert_time desc" +
" ")
List listData(@Param("startDate") String startDate,@Param("endDate") String endDate,@Param("phone") String phone,@Param("max") Integer max,@Param("min") Integer min);
(4)PageInfo类:
语言
主方法
5OaMc
54qjAzX8sX
5wd9S
r9t2PGv2V1
import java.io.Serializable;
import java.util.List;
public class PageInfo implements Serializable {
private Integer total;
private List rows;
public Integer getTotal() {
return total;
}
public void setTotal(Integer total) {
this.total = total;
}
public List getRows() {
return rows;
}
public void setRows(List rows) {
this.rows = rows;
}
}
(5)分页sql理论依据: