package cn.tsjinrong.fastfile.util;





/**

 * @ClassName: Page

 * @Description: TODO(分页组件的父类,用来封装分页的 通用内容和逻辑)

 * @author zhanghaiyang

 * @date 2016年1月14日 下午12:37:55

 * @Copyright © 2016上海通善互联网金融信息服务有限公司

 */

public class Page {





// 用户输入的分页条件

private int currentPage = 1; // 当前页

private int pageSize = 15; // 每页最大行数





// 用于实现分页SQL的条件,是根据用户输入条件计算而来的

private int begin;

private int end;





// 自动计算出的总行数

private int rows;

// 根据总行数计算总页数,然后将总页数输出给页面

private int totalPage;





public int getRows() {

return rows;

}





public void setRows(int rows) {

this.rows = rows;

}





public int getTotalPage() {

// 根据总行数,计算总页数

if (rows % pageSize == 0) {

totalPage = rows / pageSize;

} else {

totalPage = rows / pageSize + 1;

}

return totalPage;

}





public void setTotalPage(int totalPage) {

this.totalPage = totalPage;

}





public int getBegin() {

// 在mapper.xml使用begin属性时,对其进行计算

begin = (currentPage - 1) * pageSize;

return begin;

}





public void setBegin(int begin) {

this.begin = begin;

}





public int getEnd() {

// 在mapper.xml使用end属性时,对其进行计算

end = currentPage * pageSize + 1;

return end;

}





public void setEnd(int end) {

this.end = end;

}





public int getCurrentPage() {

return currentPage;

}





public void setCurrentPage(int currentPage) {

this.currentPage = currentPage;

}





public int getPageSize() {

return pageSize;

}





public void setPageSize(int pageSize) {

this.pageSize = pageSize;

}





}



public ModelAndView findVideosByPage(HttpServletRequest request, HttpServletResponse response, FileProperties fp) {





ModelAndView model = new ModelAndView("/video/video_list");

Map<String, Object> params = new HashMap<String, Object>(3);

if (StringUtils.isNotBlank(fp.getBusiId())) {

params.put("busiId", fp.getBusiId());

}

if (StringUtils.isNotBlank(fp.getApplyName())) {

params.put("applyName", fp.getApplyName());

}

if (fp.getApplyDateStart() != null && StringUtils.isNotBlank(fp.getApplyDateStart())) {

params.put("applyDateStart", DateUtil.parseDate(fp.getApplyDateStart()));

} else {

params.put("applyDateStart", DateUtil.addDay(new Date(), -7));

}

if (fp.getApplyDateEnd() != null && StringUtils.isNotBlank(fp.getApplyDateEnd())) {

params.put("applyDateEnd", DateUtil.parseDate(fp.getApplyDateEnd()));

} else {

params.put("applyDateEnd", DateUtil.format(new Date()));

}

fp.setRows(fastfileVideoService.selectRows(params));

model.addObject("fastfileVideoInfoPage", fp);

List<FastfileVideoInfo> fastfileVideoInfos = fastfileVideoService.selectByPage(fp);

model.addObject("fastfileVideoInfos", fastfileVideoInfos);

model.addObject("applyDateStart", DateUtil.format(DateUtil.addDay(new Date(), -7)));

model.addObject("applyDateEnd", DateUtil.format(new Date()));

return model;

}



<select id="selectByPage" resultMap="BaseResultMap" parameterType="cn.tsjinrong.fastfile.util.FileProperties">

select

<include refid="Base_Column_List" />

from fastfile_video_info where 1=1

<if test="busiId != null and busiId !=''">

and busi_id = #{busiId,jdbcType=VARCHAR}

</if>

<if test="applyName != null and applyName !=''">

and apply_name=#{applyName,jdbcType=VARCHAR}

</if>

<if test="applyDateStart != null and applyDateStart !=''">

and apply_date &gt;= #{applyDateStart,jdbcType=DATE}

</if>

<if test="applyDateEnd != null and applyDateEnd !=''">

and apply_date &lt;= #{applyDateEnd,jdbcType=DATE}

</if>

and del_flag = 0

order by apply_date desc limit #{beginRow},#{pageSize}

</select>

MyBatis学习总结(12)——Mybatis+Mysql分页查询的更多相关文章

  1. MyBatis学习总结(七)——Mybatis缓存(转载)

      孤傲苍狼 只为成功找方法,不为失败找借口! MyBatis学习总结(七)--Mybatis缓存 一.MyBatis缓存介绍 正如大多数持久层框架一样,MyBatis 同样提供了一级缓存和二级缓存的 ...

  2. 【转】MyBatis学习总结(一)——MyBatis快速入门

    [转]MyBatis学习总结(一)——MyBatis快速入门 一.Mybatis介绍 MyBatis是一个支持普通SQL查询,存储过程和高级映射的优秀持久层框架.MyBatis消除了几乎所有的JDBC ...

  3. 【转】MyBatis学习总结(七)——Mybatis缓存

    [转]MyBatis学习总结(七)——Mybatis缓存 一.MyBatis缓存介绍 正如大多数持久层框架一样,MyBatis 同样提供了一级缓存和二级缓存的支持 一级缓存: 基于PerpetualC ...

  4. 转:MyBatis学习总结(Mybatis总结精华文章)

    http://www.cnblogs.com/xdp-gacl/tag/MyBatis%E5%AD%A6%E4%B9%A0%E6%80%BB%E7%BB%93/ 当前标签: MyBatis学习总结   ...

  5. Mybatis学习系列(五)关联查询

    前面几节的示例基本都是一些单表查询,实际项目中,经常用到关联表的查询,比如一对一,一对多等情况.在Java实体对象中,一对一和一对多可是使用包装对象解决,属性使用List或者Set来实现,在mybat ...

  6. Mybatis学习笔记12 - 动态sql之choose(when otherwise)标签

    choose (when, otherwise):分支选择:带了break的swtich-case 示例代码: 接口定义: package com.mybatis.dao; import com.my ...

  7. MyBatis 学习记录5 MyBatis的二级缓存

    主题 之前学习了一下MyBatis的一级缓存,主要涉及到BaseExecutor这个类. 现在准备学习记录下MyBatis二级缓存. 配置二级缓存与初始化发生的事情 首先二级缓存默认是不开启的,需要自 ...

  8. MyBatis学习总结(一)——MyBatis快速入门(转载)

    本文转载自http://www.cnblogs.com/jpf-java/p/6013537.html MyBatis是一个支持普通SQL查询,存储过程和高级映射的优秀持久层框架.MyBatis消除了 ...

  9. MyBatis学习总结(一)——MyBatis快速入门

    一.Mybatis介绍 MyBatis是一个支持普通SQL查询,存储过程和高级映射的优秀持久层框架.MyBatis消除了几乎所有的JDBC代码和参数的手工设置以及对结果集的检索封装.MyBatis可以 ...

  10. MyBatis学习笔记(一)——MyBatis快速入门

    转自孤傲苍狼的博客:http://www.cnblogs.com/xdp-gacl/p/4261895.html 一.Mybatis介绍 MyBatis是一个支持普通SQL查询,存储过程和高级映射的优 ...

随机推荐

  1. SharePoint创建Alternate Access Mapping (AAM)备用訪问映射

    SharePoint创建Alternate Access Mapping (AAM)备用訪问映射         SharePoint的仓库是SQL Server中的内容数据库.这些数据库储存着组织全 ...

  2. C++ 鼠标模拟程序

    关于鼠标模拟程序应用不算少见.在游戏外挂或者一些操作频繁位置确定的程序上应用往往有奇效. 比較旧的API是mouse_event,本人一開始也用这个在搞,只是后来才看到新的API在操作上更加统一.稍作 ...

  3. 记录一下 mysql 的查询中like字段的用法

    SELECT * from t_yymp_auth_role where role_name not like '%测试%' and role_name not like '%部门%' and rol ...

  4. js正则学习分享

    http://www.cnblogs.com/rubylouvre/archive/2010/03/09/1681222.html http://www.cnblogs.com/tylerdonet/ ...

  5. Atcoder Grand Contest 107 A Biscuits

    A - Biscuits Time limit : 2sec / Memory limit : 256MB Score : 200 points Problem Statement There are ...

  6. 《五》uploadify插件上传文件

    下载地址:http://www.uploadify.com/wp-content/uploads/files/uploadify.zip 相关配置:http://www.uploadify.com/d ...

  7. 无闻go编程基础笔记

    Go语言做Web编程非常方便,并且在开发效率和程序运行效率方面都非常优秀.相比于Java,其最大的优势就是简便易用,而相比于PHP,它最大的优势就是性能好. (go做web)推荐Gorilla的库,里 ...

  8. pip-window安装

    windows 安装: 保证计算机联网直接使用cmd 执行 python -m pip install -U pip 自动安装 找到 python安装的路径 C:\Users\Administrato ...

  9. vue.js 第一课:实例化vue

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  10. HDU——T 1166 敌兵布阵

    http://acm.hdu.edu.cn/showproblem.php?pid=1166 Time Limit: 2000/1000 MS (Java/Others)    Memory Limi ...