Эх сурвалжийг харах

refactor(message): 简化用户消息查询中的条件判断逻辑

- 移除复杂的 choose-when 结构
- 使用简单的 if 条件替代原有的类型匹配逻辑
- 优化 SQL 查询中 type 字段的过滤条件
- 提高代码可读性和维护性
ChenYu 7 сар өмнө
parent
commit
9bfddd07b9

+ 8 - 11
src/main/resources/mapper/TUserMessageMapper.xml

@@ -37,17 +37,14 @@
         from t_user_message
         where user_id = #{userId}
         and order_id = #{orderId}
-        <if test="type != null">
-            <choose>
-                <!-- type=1/3 → 同时匹配 1 或 3 -->
-                <when test="type in (1, 3)">
-                    and type in (1, 3)
-                </when>
-                <!-- type=2/4/10/11 → 只匹配自身 -->
-                <when test="type in (2, 4, 10, 11)">
-                    and type = #{type}
-                </when>
-            </choose>
+        <if test="type == 1 or type == 3">
+            and (type = 1 or type = 3)
+        </if>
+        <if test="type == 2 or type == 4">
+            and type = #{type}
+        </if>
+        <if test="type == 10 or type == 11 ">
+            and type = #{type}
         </if>
     </select>