|
@@ -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);
|
|
|
}
|
|
|
|