fix(UserBalanceLog): 优化 SQL 参数空值校验
- 在多个 SQL 查询条件中添加参数非空且非空字符串判断 - 防止空字符串导致的错误匹配或异常 - 统一调整语句格式,保持代码规范和可读性 - 优化关联查询时参数过滤逻辑,提升查询准确性
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
<!-- 关联查询sql -->
|
||||
<sql id="selectSql">
|
||||
SELECT a.*,
|
||||
b.nickname,b.avatar,b.phone
|
||||
b.nickname, b.avatar, b.phone
|
||||
FROM sys_user_balance_log a
|
||||
LEFT JOIN sys_user b ON a.user_id = b.user_id
|
||||
<where>
|
||||
@@ -18,7 +18,7 @@
|
||||
<if test="param.scene != null">
|
||||
AND a.scene = #{param.scene}
|
||||
</if>
|
||||
<if test="param.sceneMultiple != null">
|
||||
<if test="param.sceneMultiple != null and param.sceneMultiple != ''">
|
||||
AND a.scene IN
|
||||
<foreach collection="param.sceneMultiple.split(',')" item="item" separator="," open="(" close=")">
|
||||
#{item}
|
||||
@@ -30,16 +30,16 @@
|
||||
<if test="param.balance != null">
|
||||
AND a.balance = #{param.balance}
|
||||
</if>
|
||||
<if test="param.describe != null">
|
||||
<if test="param.describe != null and param.describe != ''">
|
||||
AND a.describe LIKE CONCAT('%', #{param.describe}, '%')
|
||||
</if>
|
||||
<if test="param.remark != null">
|
||||
<if test="param.remark != null and param.remark != ''">
|
||||
AND a.remark LIKE CONCAT('%', #{param.remark}, '%')
|
||||
</if>
|
||||
<if test="param.sortNumber != null">
|
||||
AND a.sort_number = #{param.sortNumber}
|
||||
</if>
|
||||
<if test="param.comments != null">
|
||||
<if test="param.comments != null and param.comments != ''">
|
||||
AND a.comments LIKE CONCAT('%', #{param.comments}, '%')
|
||||
</if>
|
||||
<if test="param.status != null">
|
||||
@@ -51,7 +51,7 @@
|
||||
<if test="param.deleted == null">
|
||||
AND a.deleted = 0
|
||||
</if>
|
||||
<if test="param.merchantCode != null">
|
||||
<if test="param.merchantCode != null and param.merchantCode != ''">
|
||||
AND a.merchant_code LIKE CONCAT('%', #{param.merchantCode}, '%')
|
||||
</if>
|
||||
<if test="param.createTimeStart != null">
|
||||
@@ -60,7 +60,7 @@
|
||||
<if test="param.createTimeEnd != null">
|
||||
AND a.create_time <= #{param.createTimeEnd}
|
||||
</if>
|
||||
<if test="param.keywords != null">
|
||||
<if test="param.keywords != null and param.keywords != ''">
|
||||
AND (
|
||||
a.user_id = #{param.keywords}
|
||||
OR b.nickname LIKE CONCAT('%', #{param.keywords}, '%')
|
||||
|
||||
Reference in New Issue
Block a user