mybatis collectionc passes in multiple parameters

<?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} 
-- You don't need # when doing calculations. You can use $ symbol to do calculations. Note that double quotes will disappear when doing calculations.
    </select>
</mapper>

Guess you like

Origin blog.csdn.net/just_learing/article/details/125999646