Browse Source

fix:查重sql错误

master
buaixuexideshitongxue 4 weeks ago
parent
commit
435127e3f5
  1. 19
      src/main/resources/mapper/ComplaintCollectionMapper.xml

19
src/main/resources/mapper/ComplaintCollectionMapper.xml

@ -363,9 +363,11 @@
FROM complaint_collection cc FROM complaint_collection cc
LEFT JOIN negative n ON n.id = cc.negative_id LEFT JOIN negative n ON n.id = cc.negative_id
<where> <where>
<choose> <!-- 至少有一个参数非空时,生成括号包裹的 OR 条件 -->
<when test="(param.responderIdCode != null and param.responderIdCode != '') or (param.responderName != null and param.responderName != '') or (param.responderPhone != null and param.responderPhone != '')"> <if test="(param.responderIdCode != null and param.responderIdCode != '')
1=1 or (param.responderName != null and param.responderName != '')
or (param.responderPhone != null and param.responderPhone != '')">
<trim prefix="(" suffix=")" prefixOverrides="OR">
<if test="param.responderIdCode != null and param.responderIdCode != ''"> <if test="param.responderIdCode != null and param.responderIdCode != ''">
OR cc.responder_id_code = #{param.responderIdCode} OR cc.responder_id_code = #{param.responderIdCode}
</if> </if>
@ -375,11 +377,14 @@
<if test="param.responderPhone != null and param.responderPhone != ''"> <if test="param.responderPhone != null and param.responderPhone != ''">
OR n.contactPhone = #{param.responderPhone} OR n.contactPhone = #{param.responderPhone}
</if> </if>
</when> </trim>
<otherwise> </if>
<!-- 三个参数全为空时,强制无结果 -->
<if test="(param.responderIdCode == null or param.responderIdCode == '')
and (param.responderName == null or param.responderName == '')
and (param.responderPhone == null or param.responderPhone == '')">
1=0 1=0
</otherwise> </if>
</choose>
</where> </where>
ORDER BY cc.create_time DESC ORDER BY cc.create_time DESC
LIMIT 100 LIMIT 100

Loading…
Cancel
Save