This commit is contained in:
liuhongrui
2025-02-28 11:05:19 +08:00
parent 8547e4fcb7
commit 2b0d8a963f

View File

@@ -47,12 +47,20 @@
<!-- 如果传入name参数且不为空 --> <!-- 如果传入name参数且不为空 -->
<if test="name != null and name != ''"> <if test="name != null and name != ''">
AND pt.name LIKE CONCAT( '%', #{name}, '%') <choose>
</if> <!-- 如果name参数中包含汉字 -->
<when test="name.matches('.*[\u4e00-\u9fa5].*')">
<!-- 如果传入name参数且不为空 --> AND pt.name LIKE CONCAT('%', #{name}, '%')
<if test="name != null and name != ''"> </when>
AND pt.py_str LIKE CONCAT('%',#{name}, '%') <!-- 如果name参数中只包含字母 -->
<when test="name.matches('^[a-zA-Z]+$')">
AND pt.py_str LIKE CONCAT('%', #{name}, '%')
</when>
<!-- 如果name参数中既包含汉字又包含字母 -->
<otherwise>
AND (pt.name LIKE CONCAT('%', #{name}, '%') OR pt.py_str LIKE CONCAT('%', #{name}, '%'))
</otherwise>
</choose>
</if> </if>
</where> </where>
ORDER BY pt.bus_no ORDER BY pt.bus_no
@@ -72,11 +80,20 @@
<!-- 如果传入name参数且不为空 --> <!-- 如果传入name参数且不为空 -->
<if test="name != null and name != ''"> <if test="name != null and name != ''">
AND pt.name LIKE CONCAT('%',#{name}, '%') <choose>
</if> <!-- 如果name参数中包含汉字 -->
<!-- 如果传入name参数且不为空 --> <when test="name.matches('.*[\u4e00-\u9fa5].*')">
<if test="name != null and name != ''"> AND pt.name LIKE CONCAT('%', #{name}, '%')
AND pt.py_str LIKE CONCAT('%',#{name}, '%') </when>
<!-- 如果name参数中只包含字母 -->
<when test="name.matches('^[a-zA-Z]+$')">
AND pt.py_str LIKE CONCAT('%', #{name}, '%')
</when>
<!-- 如果name参数中既包含汉字又包含字母 -->
<otherwise>
AND (pt.name LIKE CONCAT('%', #{name}, '%') OR pt.py_str LIKE CONCAT('%', #{name}, '%'))
</otherwise>
</choose>
</if> </if>
</where> </where>
</select> </select>