// mybatis使用pageHelper插件分页查询
public PageResult pageQuery(EmployeePageQueryDTO employeePageQueryDTO) {
PageHelper.startPage(employeePageQueryDTO.getPage(), employeePageQueryDTO.getPageSize());
Page<Employee> page = employeeMapper.pageQuery(employeePageQueryDTO);
return new PageResult(page.getTotal(), page.getResult());
}
<!-- mapper.xml文件 -->
<select id="pageQuery" resultType="com.sky.entity.Employee">
select id,name,username,phone,sex,id_number,status,create_time,update_time,create_user,update_user from employee
<where>
<if test="name != null and name != ''">and name like concat('%',#{name},'%')</if>
</where>
order by create_time desc
</select>