
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC
"-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.kgc.towercrane.tchr.mapper.QueryHrMapper">
<resultMap id="emp-emp" type="EmpPage">
<result property="currentPage" column="currentpage"/>
<result property="rowPage" column="rowPage"/>
<!-- column传入多个参数 -->
<collection property="datas"
column="{c=currentPage,r=rowPage}"
ofType="EmployeesVO"
select="findEmpByPage"/>
</resultMap>
<select id="findEmp" parameterType="EmpPage" resultMap="emp-emp">
<!-- <![CDATA[转义 < -->
<![CDATA[
select ceil(count(*)/#{rowPage}) total,#{rowPage} rowPage,#{currentPage} currentPage,
if(#{currentPage}<ceil(count(*)/#{rowPage}),#{currentPage}+1,#{currentPage}) next,
if(#{currentPage}=1,#{currentPage},#{currentPage}-1) previous,
if(#{currentPage}<ceil(count(*)/#{rowPage}),1,0) hasNext,
if(#{currentPage}=1,0,1) hasPrevious from employees
]]>
</select>
<select id="findEmpByPage" resultType="EmployeesVO">
select * from employees limit ${(c-1)*r},#{r}
-- 前面做计算不用# 用$符号可以做计算 注意双引号做计算会消失
</select>
</mapper>
版权声明:本文为just_learing原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。