1. 程式人生 > >JAVA:查詢啟用禁用時,啟用正常,禁用失敗

JAVA:查詢啟用禁用時,啟用正常,禁用失敗

問題:查詢啟用禁用時,啟用正常,禁用失敗

檢查:

  1. mapper無異常,與其他條件無區別
  2. controller無異常,若為null或空字元不set
  3. 實體類new時,發現effective屬性預設值為0,其他屬性為null

原因:實體類effective為int型別初始值為0;需改為Integer,初始值為null;

總結:datatable使用時數字型別的引數都必須定義為包裝類,否則mapper中無法根據以下程式碼判斷並查詢;

switch樣式參考CSS:bootstrap中switch事件監控

    <!--分頁查詢商品列表-->
   <select id="findByPage" resultMap="base"  parameterType="DdGoods">
       SELECT g.*,d.typename, d.unit typeunit
             FROM dd_goods g
              LEFT JOIN dd_goods_type d on d.id = g.type 
                         WHERE 1 = 1
                           <if test="param.rkdNum != null ">
                               AND i.rkdNum = #{param.rkdNum}
                           </if>
                           <if test="param.num != null ">
                               AND g.num LIKE CONCAT('%',#{param.num},'%')
                           </if>
                           <if test="param.name != null and param.name != '' ">
                               AND g.name LIKE CONCAT('%',#{param.name},'%')
                           </if>
                           <if test="param.type != null ">
                               AND g.type = #{param.type}
                           </if>
                           <if test="param.brand != null ">
                               AND g.brand = #{param.brand}
                           </if>
                           <if test="param.length != null ">
                               AND g.length = #{param.length}
                           </if>
                           <if test="param.wide != null ">
                               AND g.wide = #{param.wide}
                           </if>
                           <if test="param.high != null ">
                               AND g.high = #{param.high}
                           </if>
                           <if test="param.startTime != null and param.startTime != '' ">
                               AND g.createTime &gt;= #{param.startTime}
                           </if>
                           <if test="param.endTime != null and param.endTime != '' ">
                               AND g.createTime &lt;= #{param.endTime}
                           </if>
                           <if test="param.startPrcie != null ">
                               AND g.tagPrice &gt;= #{param.startPrcie}
                           </if>
                           <if test="param.endPrcie != null ">
                               AND g.tagPrice &lt;= #{param.endPrcie}
                           </if>
                            <if test="param.effective != null ">
                               AND g.effective = #{param.effective}
                           </if>
                           <if test="param.state == -1 ">
                               GROUP BY g.id
                           </if>
                       ORDER BY g.id DESC
   </select>