Browse Source

fix(game-event):修复查询背景图和队伍信息的SQL逻辑

- 优化背景图查询逻辑,增加空值判断避免异常
- 完善运动员成绩查询条件,支持项目ID列表为空的情况
- 调整队伍批量更新SQL结构,确保参数安全传入- 保留原有删除标识过滤条件,维持数据一致性
zhou 3 weeks ago
parent
commit
fc2713b295

+ 9 - 2
ruoyi-modules/ruoyi-game-event/src/main/java/org/dromara/system/service/impl/GameEventConfigServiceImpl.java

@@ -170,11 +170,18 @@ public class GameEventConfigServiceImpl implements IGameEventConfigService {
 
     @Override
     public Long queryBgUrlByEventId(Long eventId) {
-        String ossId = baseMapper.selectOne(
+        GameEventConfig backgroundImg = baseMapper.selectOne(
             Wrappers.lambdaQuery(GameEventConfig.class)
                 .eq(GameEventConfig::getEventId, eventId)
                 .eq(GameEventConfig::getConfigKey, "background_img")
-        ).getConfigValue();
+        );
+        if (backgroundImg == null) {
+            return 0L;
+        }
+        String ossId = backgroundImg.getConfigValue();
+        if (ossId == null) {
+            return 0L;
+        }
         return Long.valueOf(ossId);
     }
 }

+ 7 - 4
ruoyi-modules/ruoyi-game-event/src/main/resources/mapper/system/GameScoreMapper.xml

@@ -32,10 +32,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     <select id="selectByAthleteAndProjects" resultType="GameScore">
         SELECT *
         FROM game_score
-        WHERE athlete_id = #{athleteId} AND project_id IN
-        <foreach item="projectId" collection="projectIds" separator="," open="(" close=")">
-            #{projectId}
-        </foreach>
+        WHERE athlete_id = #{athleteId}
+          <if test="projectIds != null and projectIds.size!=0">
+            AND project_id IN
+            <foreach item="projectId" collection="projectIds" separator="," open="(" close=")">
+                #{projectId}
+            </foreach>
+          </if>
         AND del_flag = '0'
     </select>
 </mapper>

+ 8 - 6
ruoyi-modules/ruoyi-game-event/src/main/resources/mapper/system/GameTeamMapper.xml

@@ -6,16 +6,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 
     <update id="batchUpdateRg" >
         update game_team set rg_id = #{rgId}
-        where team_id in
-        <foreach item="item" collection="teamIds" separator="," open="(" close=")">
-            #{item}
-        </foreach>
-        AND del_flag = '0'
+        where del_flag = '0'
+        <if test="teamIds != null and teamIds.size !=0">
+            and team_id in
+            <foreach item="item" collection="teamIds" separator="," open="(" close=")">
+                #{item}
+            </foreach>
+        </if>
     </update>
 
     <!-- 查询队伍列表并包含分组名 -->
     <select id="selectVoListWithGroupName" resultType="org.dromara.system.domain.vo.GameTeamVo">
-        SELECT 
+        SELECT
             gt.team_id,
             gt.event_id,
             gt.rg_id,