Kaynağa Gözat

Merge branch 'wk-dev-8-13' into dev

# Conflicts:
#	ruoyi-modules/ruoyi-game-event/src/main/java/org/dromara/system/service/impl/AdviceServiceImpl.java
wenkai 14 saat önce
ebeveyn
işleme
e5cd03aa84

+ 8 - 0
ruoyi-modules/ruoyi-game-event/src/main/java/org/dromara/system/service/IGameTeamService.java

@@ -98,6 +98,14 @@ public interface IGameTeamService {
      */
     Map<Long, String> getTeamIdAndNameMap(String eventId);
 
+
+    /**
+     * 获取队伍id和名称的映射关系
+     * @param teamIds
+     * @return
+     */
+    Map<Long, String> getTeamIdAndNameMap(Collection<Long> teamIds);
+
     /**
      * 更新队伍中的运动员列表
      *

+ 10 - 12
ruoyi-modules/ruoyi-game-event/src/main/java/org/dromara/system/service/impl/AdviceServiceImpl.java

@@ -22,9 +22,7 @@ import org.dromara.system.service.IAdviceService;
 import org.dromara.system.service.IGameTeamService;
 import org.springframework.stereotype.Service;
 
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
+import java.util.*;
 import java.util.stream.Collectors;
 
 /**
@@ -66,16 +64,16 @@ public class AdviceServiceImpl implements IAdviceService {
         bo.setEventId(defaultEventId);
         LambdaQueryWrapper<Advice> lqw = buildQueryWrapper(bo);
         Page<AdviceVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
-        result.getRecords()
+        //提前查询出队伍id和name的映射并缓存
+        Set<Long> ids = result.getRecords()
             .stream()
-            .map(vo -> {
-                GameTeamVo gameTeamVo = gameTeamService.queryById(vo.getTeamId());
-                if (gameTeamVo != null){
-                    vo.setTeamName(gameTeamVo.getTeamName());
-                }
-                return vo;
-            })
-            .collect(Collectors.toList());
+            .map(AdviceVo::getTeamId)
+            .collect(Collectors.toSet());
+        Map<Long, String> map = gameTeamService.getTeamIdAndNameMap(ids);
+        //赋值
+        result.getRecords().forEach(vo -> {
+            vo.setTeamName(map.getOrDefault(vo.getTeamId(), ""));
+        });
         return TableDataInfo.build(result);
     }
 

+ 17 - 0
ruoyi-modules/ruoyi-game-event/src/main/java/org/dromara/system/service/impl/GameTeamServiceImpl.java

@@ -371,6 +371,23 @@ public class GameTeamServiceImpl implements IGameTeamService {
         return map;
     }
 
+    /**
+     * 获取队伍id和名称的映射关系
+     *
+     * @param teamIds
+     * @return
+     */
+    @Override
+    public Map<Long, String> getTeamIdAndNameMap(Collection<Long> teamIds) {
+        List<GameTeamVo> list = baseMapper.selectVoList(
+            Wrappers.lambdaQuery(GameTeam.class)
+                .eq(GameTeam::getTeamId, teamIds)
+        );
+        Map<Long, String> map = list.stream()
+            .collect(Collectors.toMap(GameTeamVo::getTeamId, GameTeamVo::getTeamName));
+        return map;
+    }
+
     @Override
     public Long countByEventId(Long eventId) {
         return baseMapper.selectCount(

+ 0 - 1
ruoyi-modules/ruoyi-game-event/src/main/java/org/dromara/system/service/impl/IEnrollServiceImpl.java

@@ -40,7 +40,6 @@ public class IEnrollServiceImpl implements IEnrollService {
     private final IGameEventProjectService gameEventProjectService;
     private final IGameTeamService gameTeamService;
     private final IGameAthleteService gameAthleteService;
-    private final IGameEventService gameEventService;
 
     /**
      * 使用poi生成报名表模板