Integer类型传值为0时,在Mapper.xml中被 <if test="status !=null and status !=''">条件过滤

0引起的风波

昨天写了一个查询功能,如下图,“请选择”value=“” ,“正常” value=“0” ,“禁用” value=“1” ,查询的时候“正常”的结果与“请选择“的查询结果一样,DEBUG看后台的值的确是0,但是被Mybatis中if条件的 status !=’’" 过滤掉了。。。。。。>_<

去掉这个条件就。好。了

 <if test="status !=null>
 and status =  #{status,jdbcType=INTEGER}
 </if>

在这里插入图片描述

<label class="layui-form-label">状态:</label>
<div class="layui-input-block">
     <select  id="search_garastatus" name="search_garastatus" lay-filter="search_garastatus">
              <option value=""></option>
 			  <option value="0">正常</option>
 		      <option value="1">禁用</option>
      </select>
</div>
<!-- 插入集合 --> <insert id="insertListSelective" parameterType="java.util.List"> INSERT INTO art_customer_leads_pool <trim prefix="(" suffix=")" suffixOverrides=","> <if test="id != null">id,</if> <if test="activityId != null">activity_id,</if> <if test="activityName != null">activity_name,</if> <if test="comCode != null">com_code,</if> <if test="comName != null">com_name,</if> <if test="customerName != null">customer_name,</if> <if test="licenseNo != null">license_no,</if> <if test="expiryMonth != null">expiry_month,</if> <if test="mobile != null">mobile,</if> <if test="referrerStaffNo != null">referrer_staff_no,</if> <if test="referrerType != null">referrer_type,</if> <if test="status != null">status,</if> <if test="source != null">source,</if> <if test="leadInboundTime != null">lead_inbound_time,</if> <if test="createTime != null">create_time,</if> <if test="updateTime != null">update_time,</if> </trim> VALUES <foreach collection="item" index="index" item="item" separator=","> <trim prefix="(" suffix=")" suffixOverrides=","> <if test="item.id != null">#{item.id, jdbcType=BIGINT},</if> <if test="item.activityId != null">#{item.activityId, jdbcType=VARCHAR},</if> <if test="item.activityName != null">#{item.activityName, jdbcType=VARCHAR},</if> <if test="item.comCode != null">#{item.comCode, jdbcType=VARCHAR},</if> <if test="item.comName != null">#{item.comName, jdbcType=VARCHAR},</if> <if test="item.customerName != null">#{item.customerName, jdbcType=VARCHAR},</if> <if test="item.licenseNo != null">#{item.licenseNo, jdbcType=VARCHAR},</if> <if test="item.expiryMonth != null">#{item.expiryMonth, jdbcType=DATE},</if> <if test="item.mobile != null">#{item.mobile, jdbcType=VARCHAR},</if> <if test="item.referrerStaffNo != null">#{item.referrerStaffNo, jdbcType=VARCHAR},</if> <if test="item.referrerType != null">#{item.referrerType, jdbcType=VARCHAR},</if> <if test="item.status != null">#{item.status, jdbcType=SMALLINT},</if> <if test="item.source != null">#{item.source, jdbcType=VARCHAR},</if> <if test="item.leadInboundTime != null">#{item.leadInboundTime, jdbcType=DATE},</if> <if test="item.createTime != null">#{item.createTime, jdbcType=DATE},</if> <if test="item.updateTime != null">#{item.updateTime, jdbcType=DATE},</if> </trim> </foreach> </insert> public interface ArtCustomerLeadsPoolExtMapper { int insertListSelective(@Param("item") List<ArtCustomerLeadsPool> record); }我这个那里写错了
03-12
<insert id="insertListSelective"> INSERT INTO art_customer_leads_pool <trim prefix="(" suffix=")" suffixOverrides=","> <if test="item.id != null">id,</if> <if test="item.activityId != null">activity_id,</if> <if test="item.activityName != null">activity_name,</if> <if test="item.comCode != null">com_code,</if> <if test="item.comName != null">com_name,</if> <if test="item.customerName != null">customer_name,</if> <if test="item.licenseNo != null">license_no,</if> <if test="item.expiryMonth != null">expiry_month,</if> <if test="item.mobile != null">mobile,</if> <if test="item.referrerStaffNo != null">referrer_staff_no,</if> <if test="item.referrerType != null">referrer_type,</if> <if test="item.status != null">status,</if> <if test="item.source != null">source,</if> <if test="item.leadInboundTime != null">lead_inbound_time,</if> <if test="item.createTime != null">create_time,</if> <if test="item.updateTime != null">update_time,</if> </trim> VALUES <foreach collection="records" item="item" separator=","> ( <trim prefix="(" suffix=")" suffixOverrides=","> <if test="item.id != null">#{item.id,jdbcType=BIGINT},</if> <if test="item.activityId != null">#{item.activityId,jdbcType=VARCHAR},</if> <if test="item.activityName != null">#{item.activityName,jdbcType=VARCHAR},</if> <if test="item.comCode != null">#{item.comCode,jdbcType=VARCHAR},</if> <if test="item.comName != null">#{item.comName,jdbcType=VARCHAR},</if> <if test="item.customerName != null">#{item.customerName,jdbcType=VARCHAR},</if> <if test="item.licenseNo != null">#{item.licenseNo,jdbcType=VARCHAR},</if> <if test="item.expiryMonth != null">#{item.expiryMonth,jdbcType=DATE},</if> <if test="records.mobile != null">#{item.mobile,jdbcType=VARCHAR},</if> <if test="item.referrerStaffNo != null">#{item.referrerStaffNo,jdbcType=VARCHAR},</if> <if test="item.referrerType != null">#{item.referrerType,jdbcType=VARCHAR},</if> <if test="item.status != null">#{item.status,jdbcType=INTEGER},</if> <!-- 假设是整数 --> <if test="item.source != null">#{item.source,jdbcType=VARCHAR},</if> <if test="item.leadInboundTime != null">#{item.leadInboundTime,jdbcType=TIMESTAMP},</if> <if test="item.createTime != null">#{item.createTime,jdbcType=TIMESTAMP},</if> <if test="item.updateTime != null">#{item.updateTime,jdbcType=TIMESTAMP}</if> </trim> ) </foreach> </insert>,帮我修改一下这个方法让他可以正常运行 int insertListSelective(@Param("item") List<ArtCustomerLeadsPool> record);
03-12
<?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.qs.birp.jgAudit.JgAuditHeadDao"> <select id="getReqByReqNo" resultType="jg_audit_head" parameterType="String"> select * from jg_audit_head where request_no = #{request_no} limit 1; </select> <select id="showJgAuditHead" resultType="jg_audit_head"> SELECT * FROM jg_audit_head <where> and is_show = "1" <if test='request_no !=null and request_no !=""'>and request_no =#{request_no} </if> <if test='purchase_no !=null and purchase_no !=""'>and purchase_no =#{purchase_no} </if> <if test='project_number !=null and project_number !=""'>and project_number =#{project_number} </if> <if test='project_name !=null and project_name !=""'> and project_name like "%"#{project_name}"%"</if> <if test='company_code !=null and company_code !=""'>and company_code =#{company_code} </if> <if test='sssdwdm !=null and sssdwdm !=""'>and sssdwdm =#{sssdwdm}</if> <if test='ssxdwdm !=null and ssxdwdm !=""'>and ssxdwdm =#{ssxdwdm}</if> <if test='status !=null and status !=""'>and status =#{status}</if> <if test='company_code_values!=null and company_code_values.size()>0'> and company_code in <foreach collection="company_code_values" item="item" open="(" separator="," close=")"> #{item} </foreach> </if> </where> limit #{currIndex}, #{pageSize} ; </select> <select id="showJgAuditHeadCount" resultType="Integer"> SELECT count(*) FROM jg_audit_head <where> and is_show = "1" <if test='request_no !=null and request_no !=""'>and request_no =#{request_no} </if> <if test='purchase_no !=null and purchase_no !=""'>and purchase_no =#{purchase_no} </if> <if test='project_number !=null and project_number !=""'>and project_number =#{project_number} </if> <if test='project_name !=null and project_name !=""'> and project_name like "%"#{project_name}"%"</if> <if test='company_code !=null and company_code !=""'>and company_code =#{company_code} </if> <if test='sssdwdm !=null and sssdwdm !=""'>and sssdwdm =#{sssdwdm}</if> <if test='ssxdwdm !=null and ssxdwdm !=""'>and ssxdwdm =#{ssxdwdm}</if> <if test='status !=null and status !=""'>and status =#{status}</if> <if test='company_code_values!=null and company_code_values.size()>0'> and company_code in <foreach collection="company_code_values" item="item" open="(" separator="," close=")"> #{item} </foreach> </if> </where> </select> </mapper> 请你帮我分析 什么原因导致服务起不来
03-08
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值