|
|
@@ -3,12 +3,17 @@ package cn.iocoder.byzs.module.web.service.blockly;
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
import cn.iocoder.byzs.framework.common.enums.CommonStatusEnum;
|
|
|
import cn.iocoder.byzs.framework.common.util.object.BeanUtils;
|
|
|
+import cn.iocoder.byzs.framework.web.core.util.WebFrameworkUtils;
|
|
|
import cn.iocoder.byzs.module.blockly.controller.admin.blockly.vo.BlocklyPageReqVO;
|
|
|
import cn.iocoder.byzs.module.blockly.controller.admin.blocklyConfig.vo.BlocklyConfigRespVO;
|
|
|
import cn.iocoder.byzs.module.blockly.service.blockly.BlocklyService;
|
|
|
import cn.iocoder.byzs.module.blockly.service.blocklyConfig.BlocklyConfigService;
|
|
|
+import cn.iocoder.byzs.module.blockly.service.blocklyType.BlocklyTypeService;
|
|
|
+import cn.iocoder.byzs.module.web.controller.admin.blockly.vo.WebBlocklyTypeVO;
|
|
|
import cn.iocoder.byzs.module.web.controller.admin.blockly.vo.WebBlocklyVO;
|
|
|
+import cn.iocoder.byzs.module.web.controller.admin.blocklyprogress.vo.WebBlocklyProgressDO;
|
|
|
import cn.iocoder.byzs.module.web.dal.mysql.blockly.WebBlocklyMapper;
|
|
|
+import cn.iocoder.byzs.module.web.service.blocklyprogress.WebBlocklyProgressServiceImpl;
|
|
|
import jakarta.annotation.Resource;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
@@ -16,6 +21,8 @@ import org.springframework.validation.annotation.Validated;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Comparator;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* web课程 Service 实现类
|
|
|
@@ -26,38 +33,76 @@ import java.util.List;
|
|
|
@Validated
|
|
|
public class WebBlocklyServiceImpl {
|
|
|
|
|
|
+ @Resource
|
|
|
+ private BlocklyTypeService blocklyTypeService;
|
|
|
@Resource
|
|
|
private BlocklyService blocklyService;
|
|
|
@Resource
|
|
|
private BlocklyConfigService blocklyConfigService;
|
|
|
@Resource
|
|
|
private WebBlocklyMapper webBlocklyMapper;
|
|
|
+ @Resource
|
|
|
+ private WebBlocklyProgressServiceImpl webBlocklyProgressService;
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
+ * 根据课程类型id查询课程列表
|
|
|
+ *
|
|
|
+ * @param typeId 课程类型id
|
|
|
+ * @return 课程列表
|
|
|
+ */
|
|
|
public List<WebBlocklyVO> getBlocklyVoByTypeId(Long typeId) {
|
|
|
List<BlocklyPageReqVO> blocklyList = blocklyService.getBlocklyList(new BlocklyPageReqVO().setBcType(typeId).setBcStatus(String.valueOf(CommonStatusEnum.ENABLE.getStatus())));
|
|
|
|
|
|
- // 目前数据少先循环查询即可
|
|
|
-// List<Long> idList = blocklyList.stream()
|
|
|
-// .map(BlocklyPageReqVO::getId)
|
|
|
-// .collect(Collectors.toList());
|
|
|
+ //填充课程配置
|
|
|
+ List<Long> idList = blocklyList.stream()
|
|
|
+ .map(BlocklyPageReqVO::getId)
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ List<BlocklyConfigRespVO> blocklyConfigQuestionList = blocklyConfigService.getBlocklyConfigQuestionByCourseIds(idList);
|
|
|
+ Map<Long, List<BlocklyConfigRespVO>> blocklyConfigQuestionMap = blocklyConfigQuestionList.stream().collect(Collectors.groupingBy(BlocklyConfigRespVO::getCcCourseId));
|
|
|
|
|
|
- //优化需要走web端类
|
|
|
-// webBlocklyMapper
|
|
|
+ //课程小节进度
|
|
|
+ List<WebBlocklyProgressDO> progressList = webBlocklyProgressService.getBlocklyProgressByTypeId(typeId);
|
|
|
+ Map<Long, WebBlocklyProgressDO> progressMap = progressList.stream().collect(Collectors.toMap(WebBlocklyProgressDO::getBrpUserId, a -> a));
|
|
|
|
|
|
- List<WebBlocklyVO> blocklyVoList = new ArrayList<>();
|
|
|
|
|
|
+
|
|
|
+ //重新组装
|
|
|
+ List<WebBlocklyVO> blocklyVoList = new ArrayList<>();
|
|
|
for (BlocklyPageReqVO blockly : blocklyList) {
|
|
|
- List<BlocklyConfigRespVO> blocklyConfigQuestion = blocklyConfigService.getBlocklyConfigQuestion(blockly.getId());
|
|
|
+
|
|
|
+ //组装试题配置
|
|
|
+ List<BlocklyConfigRespVO> blocklyConfigQuestion = blocklyConfigQuestionMap.get(blockly.getId());
|
|
|
List<BlocklyConfigRespVO> list = new ArrayList<>();
|
|
|
+
|
|
|
+ WebBlocklyVO webBlocklyVO = BeanUtils.toBean(blockly, WebBlocklyVO.class);
|
|
|
if (CollUtil.isNotEmpty(blocklyConfigQuestion)) {
|
|
|
- // 根据 ccTime 升序排序(已满足需求)
|
|
|
+ // 根据 ccTime 升序排序(弹框时间)
|
|
|
list = blocklyConfigQuestion.stream().sorted(Comparator.comparing(BlocklyConfigRespVO::getCcTime)).toList();
|
|
|
}
|
|
|
- blocklyVoList.add(BeanUtils.toBean(blockly, WebBlocklyVO.class).setBlocklyConfigList(list));
|
|
|
+ webBlocklyVO.setBlocklyConfigList(list);
|
|
|
+
|
|
|
+ //填充进度
|
|
|
+ if (progressMap.containsKey(blockly.getId())) {
|
|
|
+ WebBlocklyProgressDO progress = progressMap.get(blockly.getId());
|
|
|
+ webBlocklyVO.setProgress(progress.getBrpProgress().intValue());
|
|
|
+ }else{
|
|
|
+ webBlocklyVO.setProgress(0);
|
|
|
+ }
|
|
|
+
|
|
|
+ blocklyVoList.add(webBlocklyVO);
|
|
|
}
|
|
|
|
|
|
return blocklyVoList;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 根据课程类型查询课程类型列表
|
|
|
+ * @param themeId
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public List<WebBlocklyTypeVO> getTypeByThemeId(Integer themeId) {
|
|
|
+ WebBlocklyTypeVO blocklyTypeVO = new WebBlocklyTypeVO().setCtParentId(themeId).setUserId(WebFrameworkUtils.getLoginUserId());
|
|
|
+ return webBlocklyMapper.getTypeByThemeId(blocklyTypeVO);
|
|
|
+ }
|
|
|
}
|