|
|
@@ -53,7 +53,31 @@ public class FsUserCourseTrainingCampServiceImpl extends ServiceImpl<FsUserCours
|
|
|
@Override
|
|
|
public List<FsUserCourseTrainingCampVO> selectFsUserCourseTrainingCampVOListByMap(Map<String, Object> params) {
|
|
|
List<FsUserCourseTrainingCampVO> trainingCampVOS = baseMapper.selectFsUserCourseTrainingCampVOListByMap(params);
|
|
|
- trainingCampVOS.forEach(camp -> camp.setVipCount(fsCourseWatchLogMapper.getUserCountByCampId(camp.getTrainingCampId())));
|
|
|
+// trainingCampVOS.forEach(camp -> camp.setVipCount(fsCourseWatchLogMapper.getUserCountByCampId(camp.getTrainingCampId())));
|
|
|
+ if (CollectionUtils.isNotEmpty(trainingCampVOS)) {
|
|
|
+ // 提取所有训练营 ID
|
|
|
+ List<Long> campIds = trainingCampVOS.stream()
|
|
|
+ .map(FsUserCourseTrainingCampVO::getTrainingCampId)
|
|
|
+ .collect(Collectors.toList());
|
|
|
+
|
|
|
+ // 批量查询每个训练营的看课人数
|
|
|
+ List<Map<String, Object>> countMaps = fsCourseWatchLogMapper.getUserCountByCampIds(campIds);
|
|
|
+
|
|
|
+ // 转换为 Map<campId, vipCount>
|
|
|
+ Map<Long, Integer> vipCountMap = countMaps.stream()
|
|
|
+ .collect(Collectors.toMap(
|
|
|
+ map -> ((Number) map.get("trainingCampId")).longValue(),
|
|
|
+ map -> ((Number) map.get("vipCount")).intValue(),
|
|
|
+ (v1, v2) -> v1
|
|
|
+ ));
|
|
|
+
|
|
|
+ // 设置 vipCount
|
|
|
+ trainingCampVOS.forEach(camp -> {
|
|
|
+ Integer vipCount = vipCountMap.getOrDefault(camp.getTrainingCampId(), 0);
|
|
|
+ camp.setVipCount(vipCount);
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
return trainingCampVOS;
|
|
|
}
|
|
|
|