瀏覽代碼

refactor(系统模块): 优化比赛盲注结构查询 SQL 语句

- 格式化 SQL 语句,提高可读性
- 修改 tournamentsName 字段的查询方式,使用小写
- 优化 allocationStatus 字段的 CASE 语句逻辑
fugui001 6 月之前
父節點
當前提交
049b77c3b7
共有 1 個文件被更改,包括 14 次插入11 次删除
  1. 14 11
      ruoyi-modules/ruoyi-system/src/main/resources/mapper/business/TournamentsMapper.xml

+ 14 - 11
ruoyi-modules/ruoyi-system/src/main/resources/mapper/business/TournamentsMapper.xml

@@ -78,18 +78,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 
     <select id="selectTournamentBlindStructuresList" resultType="org.dromara.business.domain.vo.TournamentBlindStructuresListVo">
         SELECT
-            a.id AS blindStructuresId,
-            a.NAME AS blindStructuresName,
-            a.description AS blindDescription,
-            c.NAME AS tournamentsName,
-            ( CASE b.tournament_id WHEN b.tournament_id IS NOT NULL THEN 1 ELSE 0 END ) AS allocationStatus
+        a.id AS blindStructuresId,
+        a.name AS blindStructuresName,
+        a.description AS blindDescription,
+        c.name AS tournamentsName,
+        CASE
+        WHEN b.tournament_id IS NOT NULL OR b.tournament_id > 0 THEN 1
+        ELSE 0
+        END AS allocationStatus
         FROM
-            blind_structures a
-                LEFT JOIN tournament_blind_structures b ON a.id = b.blind_structure_id
-                <if test="query.tournamentId != null and query.tournamentId != 0">
-                    AND b.tournament_id = #{query.tournamentId}
-                </if>
-                LEFT JOIN tournaments c ON b.tournament_id = c.id
+        blind_structures a
+        LEFT JOIN tournament_blind_structures b ON a.id = b.blind_structure_id
+        <if test="query.tournamentId != null and query.tournamentId != 0">
+            AND b.tournament_id = #{query.tournamentId}
+        </if>
+        LEFT JOIN tournaments c ON b.tournament_id = c.id
     </select>