WonYong-Jang / Spring-Jquery-Project

0 stars 0 forks source link

[ mybatis ] / 복잡한 resultMap / jqGrid paging #6

Open WonYong-Jang opened 5 years ago

WonYong-Jang commented 5 years ago
<select id="selectJqgridList" parameterType="jqgridVO" resultType="egovMap">
        SELECT  a.*
          FROM  (
            SELECT  a.*,
                    ROWNUM rnum,
                    FLOOR((ROWNUM - 1) /#{rows} + 1) pageNumber
              FROM  (
                    SELECT  seq
                         , name
                         , phone
                         , address
                         , etcc
                         , gender
                      FROM jqgrid_start
                     WHERE 1=1
                     <if test='serviceImplYn != null'>
                         <choose>
                             <when test='serviceImplYn == "A"'>
                                 AND name = 'dddd'
                             </when>
                               <when test='serviceImplYn == "B"'>
                                 AND name = 'shink'
                             </when>
                             <when test='serviceImplYn == "D"'>
                                 AND name = 'rrrr'
                             </when>
                             <otherwise>
                             </otherwise>
                         </choose>
                    </if>
                 ORDER BY seq ASC
                    ) a
                ) a
           WHERE  a.pageNumber = #{page}
        order by a.rnum
    </select>

    <select id="selectJqgridListCnt" parameterType="jqgridVO" resultType="egovMap">
        SELECT  count(*) totalTotCnt
              , CEIL(count(*) / #{rows}) totalPage
          FROM  jqgrid_start
         WHERE  1=1
      ORDER BY  seq ASC
    </select>

출처: https://pjh3749.tistory.com/154 [JayTech의 기술 블로그]