引入插件
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper-spring-boot-starter</artifactId>
<version>1.2.3</version>
</dependency>
插件参数配置
pagehelper:
helper-dialect: mysql
reasonable: true
support-methods-arguments: true
params: count=countsql
使用
select
<include refid="Base_Column_List" />
from `t_report_template`
where 1=1
and data_state != 'DELETED'
<if test="reportName!=null and reportName!=''">
and report_name = #{reportName,jdbcType=VARCHAR}
</if>
<if test="personId!=null and personId!=''">
and person_id = #{personId,jdbcType=VARCHAR}
</if>
<if test="startTime!=null">
AND <![CDATA[ create_time >= #{startTime,jdbcType=TIMESTAMP} ]]>
</if>
<if test="endTime!=null">
AND <![CDATA[ create_time <= #{endTime,jdbcType=TIMESTAMP} ]]>
</if>
order by create_time desc
/**
* 查询模板列表
*
* @param params 参数
* @return 结果
*/
List<TemplateDto> queryTemplates(ReportRequest params);
@Override
public PageInfo<TemplateDto> queryTemplates(ReportRequest request) {
if (request == null) {
return null;
}
int currentPage = request.getCurrentPage();
int pageSize = request.getPageSize();
PageHelper.startPage(currentPage,pageSize);
List<TemplateDto> templateDtoList = templateMapper.queryTemplates(request);
return new PageInfo<>(templateDtoList);
}
网友评论