首页 技术 正文
技术 2022年11月17日
0 收藏 664 点赞 2,332 浏览 2964 个字

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>

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,027
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,518
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,365
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,146
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,780
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,857