阅读背景:

mybatis 全查 分页 模糊查询一体

来源:互联网 

配置xml文件

<resultMap id="BaseResultMap" type="com.huyuqiang.vo.ptNotice.PtNoticeVo">
    <id column="NOTICE_ID" property="noticeId" jdbcType="VARCHAR"/>
    <result column="NOTICE_TITLE" property="noticeTitle" jdbcType="VARCHAR"/>
    <result column="DATETIME" property="datetime" jdbcType="TIMESTAMP"/>
    <result column="TYPE" property="type" jdbcType="VARCHAR"/>
</resultMap>
 <!-- 全查 分页 模糊-->
  <select id="selectAll" resultMap="BaseResultMap" parameterType="com.huyuqiang.vo.ptNotice.PtNoticeVo">
      SELECT NOTICE_ID,NOTICE_TITLE,TYPE,DATETIME FROM pt_notice
      <where>
          <if test=" ptNoticeVo.type != null and ptNoticeVo.type != '' ">
              <bind name="fType" value=" '%' + ptNoticeVo.type + '%' "></bind>
              type like #{fType}
          </if>
          <if test=" ptNoticeVo.noticeTitle != null and ptNoticeVo.noticeTitle != '' ">
              <bind name="noticeTitlef" value=" '%' + ptNoticeVo.noticeTitle + '%' "></bind>
              AND NOTICE_TITLE like #{noticeTitlef}
          </if>
      </where>
      limit #{startIndex},#{pageSize}
  </select>
  <!--统计总数-->
  <select id="count" resultType="int" parameterType="com.huyuqiang.vo.ptNotice.PtNoticeVo">
  select count(*)
  from pt_notice
      <where>
          <if test=" ptNoticeVo.type != null and ptNoticeVo.type != '' ">
              <bind name="fType" value=" '%' + ptNoticeVo.type + '%' "></bind>
              type like #{fType}
          </if>
          <if test=" ptNoticeVo.noticeTitle != null and ptNoticeVo.noticeTitle != '' ">
              <bind name="noticeTitlef" value=" '%' + ptNoticeVo.noticeTitle + '%' "></bind>
              AND NOTICE_TITLE like #{noticeTitlef}
          </if>
      </where>
</select>
<resultMap id="BaseResultMap" typ



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: