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>

猜你喜欢

转载自blog.csdn.net/u011374582/article/details/83685231
今日推荐