|
@@ -10,8 +10,6 @@ import com.ym.mec.auth.api.entity.SysUser;
|
|
|
import com.ym.mec.biz.dal.dao.CloudTeacherOrderDao;
|
|
|
import com.ym.mec.biz.dal.entity.*;
|
|
|
import com.ym.mec.biz.dal.enums.ClientEnum;
|
|
|
-import com.ym.mec.biz.dal.entity.Subject;
|
|
|
-import com.ym.mec.biz.dal.enums.ClientEnum;
|
|
|
import com.ym.mec.biz.dal.wrapper.LessonCoursewareWrapper;
|
|
|
import com.ym.mec.biz.service.*;
|
|
|
import com.ym.mec.common.controller.BaseController;
|
|
@@ -22,13 +20,15 @@ import com.ym.mec.common.page.PageUtil;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
import org.jetbrains.annotations.NotNull;
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import java.util.ArrayList;
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@RequestMapping("${app-config.url.student:}/lessonCourseware")
|
|
@@ -47,15 +47,18 @@ public class LessonCoursewareController extends BaseController {
|
|
|
@Resource
|
|
|
private CbsMusicScoreCategoriesService cbsMusicScoreCategoriesService;
|
|
|
|
|
|
- @Autowired
|
|
|
+ @Resource
|
|
|
private CloudTeacherOrderDao cloudTeacherOrderDao;
|
|
|
|
|
|
- @Autowired
|
|
|
+ @Resource
|
|
|
private MemberRankCourseTypeMapperService memberRankCourseTypeMapperService;
|
|
|
|
|
|
- @Autowired
|
|
|
+ @Resource
|
|
|
private MemberRankCategoryMapperService memberRankCategoryMapperService;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private SysMusicScoreService sysMusicScoreService;
|
|
|
+
|
|
|
@ApiOperation(value = "分页查询已添加的课件")
|
|
|
@PostMapping("/queryLessonCourseware")
|
|
|
public HttpResponseResult<PageInfo<LessonCoursewareWrapper.LessonCoursewareDto>> queryLessonCourseware(@RequestBody LessonCoursewareWrapper.LessonCoursewareQuery query){
|
|
@@ -129,16 +132,87 @@ public class LessonCoursewareController extends BaseController {
|
|
|
|
|
|
@ApiOperation(value = "获取课件关联的课程列表")
|
|
|
@GetMapping("/getLessonCoursewareCourseList/{id}")
|
|
|
- public HttpResponseResult<List<LessonCoursewareWrapper.CourseScheduleCoursewareDetail>> getLessonCoursewareCourseList(@PathVariable("id") Long id){
|
|
|
- List<CbsLessonCoursewareWrapper.CourseScheduleCoursewareDetail> courseScheduleCoursewareDetails = coursewareFeignService.coursewareDetail(id).feignData();
|
|
|
+ public HttpResponseResult<List<LessonCoursewareWrapper.CourseScheduleCoursewareDetail>> getLessonCoursewareCourseList(@PathVariable("id") Long id,
|
|
|
+ String search,
|
|
|
+ Boolean detailFlag){
|
|
|
+ CbsLessonCoursewareWrapper.CoursewareDetailQuery query = new CbsLessonCoursewareWrapper.CoursewareDetailQuery();
|
|
|
+ query.setId(id);
|
|
|
+ query.setSearch(search);
|
|
|
+ query.setDetailFlag(detailFlag);
|
|
|
+ List<CbsLessonCoursewareWrapper.CourseScheduleCoursewareDetail> courseScheduleCoursewareDetails = coursewareFeignService.coursewareDetail(query).feignData();
|
|
|
if (CollectionUtils.isNotEmpty(courseScheduleCoursewareDetails)) {
|
|
|
+ SysUser sysUser = sysUserService.getUser();
|
|
|
+ // 机构可用曲目分类
|
|
|
+ String teachingMaterialIds = organizationService.getTeachingMaterialIds(sysUser.getOrganId().toString(),sysUser.getTenantId());
|
|
|
+ List<Integer> categoryIdList = cbsMusicScoreCategoriesService.getAllCategoryIdList(teachingMaterialIds);
|
|
|
+ // 学生会员可用曲目分类
|
|
|
+ List<Integer> activationVipIds = cloudTeacherOrderDao.getActivationVipIds(sysUser.getId());
|
|
|
+ // 获取会员的曲目分类
|
|
|
+ List<Integer> categoryIds = new ArrayList<>();
|
|
|
+ if (CollectionUtils.isNotEmpty(activationVipIds)) {
|
|
|
+ List<MemberRankCategoryMapper> categoryMapperList = memberRankCategoryMapperService.getByMemberRankId(activationVipIds);
|
|
|
+ if (CollectionUtils.isEmpty(categoryMapperList)) {
|
|
|
+ categoryMapperList = new ArrayList<>();
|
|
|
+ }
|
|
|
+ categoryIds = categoryMapperList.stream().map(MemberRankCategoryMapper::getCategoryId)
|
|
|
+ .distinct().collect(Collectors.toList());
|
|
|
+ }
|
|
|
+ LessonCoursewareWrapper.LessonCoursewareDetailQuery query1 = new LessonCoursewareWrapper.LessonCoursewareDetailQuery();
|
|
|
+ query1.setUserType(ClientEnum.STUDENT);
|
|
|
+ query1.setTenantCategoriesIdList(categoryIdList);
|
|
|
+ query1.setStudentCategoriesIdList(categoryIds);
|
|
|
+ //获取课件下面包含的所有的曲目编号
|
|
|
+ List<Long> musicScoreIds = lessonCoursewareService.getMusicScoreIds(courseScheduleCoursewareDetails);
|
|
|
+ Map<Long, SysMusicScore> musicScoreMap = new HashMap<>();
|
|
|
+ if (CollectionUtils.isNotEmpty(musicScoreIds)) {
|
|
|
+ List<SysMusicScore> musicScores = sysMusicScoreService.getDao().findByCbsId(musicScoreIds,false);
|
|
|
+ musicScoreMap = musicScores.stream().collect(Collectors.toMap(e -> Long.parseLong(e.getCbsMusicSheetId()), o -> o));
|
|
|
+ }
|
|
|
+ for (CbsLessonCoursewareWrapper.CourseScheduleCoursewareDetail e : courseScheduleCoursewareDetails) {
|
|
|
+ lessonCoursewareService.setTreeResourceId(e.getKnowledgePointList(), query1, musicScoreMap);
|
|
|
+ }
|
|
|
+ courseScheduleCoursewareDetails.removeIf(courseScheduleCoursewareDetail -> !filterAndUpdateKnowledgePointList(courseScheduleCoursewareDetail));
|
|
|
String jsonString = JSONObject.toJSONString(courseScheduleCoursewareDetails);
|
|
|
- List<LessonCoursewareWrapper.CourseScheduleCoursewareDetail> courseScheduleCoursewareDetailList = JSONObject.parseArray(jsonString, LessonCoursewareWrapper.CourseScheduleCoursewareDetail.class);
|
|
|
+ List<LessonCoursewareWrapper.CourseScheduleCoursewareDetail> courseScheduleCoursewareDetailList =
|
|
|
+ JSONObject.parseArray(jsonString, LessonCoursewareWrapper.CourseScheduleCoursewareDetail.class);
|
|
|
return succeed(courseScheduleCoursewareDetailList);
|
|
|
}
|
|
|
return succeed(new ArrayList<>());
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ private boolean filterAndUpdateKnowledgePointList(CbsLessonCoursewareWrapper.CourseScheduleCoursewareDetail courseScheduleCoursewareDetail) {
|
|
|
+ List<CbsLessonCoursewareDetailWrapper.KnowledgePointSmall> knowledgePointList = courseScheduleCoursewareDetail.getKnowledgePointList();
|
|
|
+ if (CollectionUtils.isEmpty(knowledgePointList)) {
|
|
|
+ return false; // 如果 knowledgePointList 为空,直接返回 false,后续会删除该 courseScheduleCoursewareDetail
|
|
|
+ }
|
|
|
+
|
|
|
+ // 过滤 KnowledgePointSmall
|
|
|
+ knowledgePointList.removeIf(knowledgePointSmall -> !filterKnowledgePoint(knowledgePointSmall));
|
|
|
+ courseScheduleCoursewareDetail.setKnowledgePointList(knowledgePointList);
|
|
|
+
|
|
|
+ // 如果过滤后的 knowledgePointList 为空,返回 false
|
|
|
+ return CollectionUtils.isNotEmpty(knowledgePointList);
|
|
|
+ }
|
|
|
+
|
|
|
+ private boolean filterKnowledgePoint(CbsLessonCoursewareDetailWrapper.KnowledgePointSmall knowledgePointSmall) {
|
|
|
+ // 过滤 materialList
|
|
|
+// if (CollectionUtils.isNotEmpty(knowledgePointSmall.getMaterialList())) {
|
|
|
+// filterAndUpdateMaterialList(knowledgePointSmall.getMaterialList(), search);
|
|
|
+// }
|
|
|
+ // 过滤子知识点 children
|
|
|
+ if (CollectionUtils.isNotEmpty(knowledgePointSmall.getChildren())) {
|
|
|
+ knowledgePointSmall.getChildren().removeIf(child -> !filterKnowledgePoint(child));
|
|
|
+ }
|
|
|
+ // 保留当前的条件:materialList 不为空 或者 children 不为空,**否则删除当前节点**
|
|
|
+ return CollectionUtils.isNotEmpty(knowledgePointSmall.getMaterialList()) ||
|
|
|
+ CollectionUtils.isNotEmpty(knowledgePointSmall.getChildren());
|
|
|
+ }
|
|
|
+
|
|
|
+ private void filterAndUpdateMaterialList(List<CbsLessonCoursewareDetailWrapper.MaterialSmall> materialList, String search) {
|
|
|
+ materialList.removeIf(materialSmall -> !materialSmall.getName().contains(search));
|
|
|
+ }
|
|
|
+
|
|
|
@ApiOperation(value = "获取课程详情")
|
|
|
@GetMapping("/getLessonCourseDetail/{id}")
|
|
|
public HttpResponseResult<CbsLessonCoursewareDetailWrapper.LessonCoursewareDetail> getLessonCourseDetail(@PathVariable("id") Long id){
|
|
@@ -148,8 +222,7 @@ public class LessonCoursewareController extends BaseController {
|
|
|
List<Integer> categoryIdList = cbsMusicScoreCategoriesService.getAllCategoryIdList(teachingMaterialIds);
|
|
|
|
|
|
// 学生会员可用曲目分类
|
|
|
- Integer userId = sysUserService.getUserId();
|
|
|
- List<Integer> activationVipIds = cloudTeacherOrderDao.getActivationVipIds(userId);
|
|
|
+ List<Integer> activationVipIds = cloudTeacherOrderDao.getActivationVipIds(sysUser.getId());
|
|
|
|
|
|
// 获取会员的曲目分类
|
|
|
|