bootStrap-table前端表格接收数据格式后台实现

(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<PhoneInfo> 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(" <script> " +
            " select count(*) from phoneTable t " +
            " <where>"+
            " <if test='phone !=null and phone!=\"\"'>" +
            " and t.phone like '%${phone}%'" +
            " </if> " +
            " <if test='startDate !=null and startDate!=\"\"'> " +
            " and t.insert_time &gt;= to_date('${startDate}','yyyy-mm-dd hh24:mi:ss') " +
            " </if> " +
            " <if test='endDate !=null and endDate!=\"\"'> " +
            " and t.insert_time &lt;= to_date('${endDate}','yyyy-mm-dd hh24:mi:ss') " +
            " </if>" +
            " </where>" +
             " </script>")
    int countData(@Param("startDate") String startDate,@Param("endDate") String endDate,@Param("phone") String phone);

    @Select(" <script> " +
            " 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 " +
            " <where>" +
            " <if test='max!=null and max!=\"\"'>" +
            " and ROWNUM &lt;= ${max}" +
            " </if>"+
            " <if test='phone !=null and phone!=\"\"'>" +
            " and t.phone like '%${phone}%'" +
            " </if> " +
            " <if test='startDate !=null and startDate!=\"\"'> " +
            " and t.insert_time &gt;= to_date('${startDate}','yyyy-mm-dd hh24:mi:ss') " +
            " </if> " +
            " <if test='endDate !=null and endDate!=\"\"'> " +
            " and t.insert_time &lt;= to_date('${endDate}','yyyy-mm-dd hh24:mi:ss') " +
            " </if>" +
            " </where>)t2 " +
            " <where>" +
            " <if test='min !=null and min !=\"\"'>" +
            " t2.rn &gt; ${min}" +
            " </if>" +
            " </where>" +
            " order by t2.insert_time desc" +
            " </script>")
    List<PhoneInfo> listData(@Param("startDate") String startDate,@Param("endDate") String endDate,@Param("phone") String phone,@Param("max") Integer max,@Param("min") Integer min);

(4)PageInfo类:

import java.io.Serializable;
import java.util.List;

public class PageInfo<T> implements Serializable {
    private Integer total;

    private List<T> rows;

    public Integer getTotal() {
        return total;
    }

    public void setTotal(Integer total) {
        this.total = total;
    }

    public List<T> getRows() {
        return rows;
    }

    public void setRows(List<T> rows) {
        this.rows = rows;
    }
}

(5)分页sql理论依据:

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

郝少

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值