|
@@ -7,24 +7,27 @@ import com.dayaedu.cbs.openfeign.wrapper.courseware.CbsLessonCoursewareDetailWra
|
|
|
import com.dayaedu.cbs.openfeign.wrapper.courseware.CbsLessonCoursewareWrapper;
|
|
|
import com.microsvc.toolkit.common.response.paging.QueryInfo;
|
|
|
import com.ym.mec.auth.api.entity.SysUser;
|
|
|
-import com.ym.mec.biz.dal.entity.Subject;
|
|
|
+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.wrapper.LessonCoursewareWrapper;
|
|
|
-import com.ym.mec.biz.service.CbsMusicScoreCategoriesService;
|
|
|
-import com.ym.mec.biz.service.LessonCoursewareService;
|
|
|
-import com.ym.mec.biz.service.OrganizationService;
|
|
|
-import com.ym.mec.biz.service.SysUserService;
|
|
|
+import com.ym.mec.biz.service.*;
|
|
|
import com.ym.mec.common.controller.BaseController;
|
|
|
import com.ym.mec.common.entity.HttpResponseResult;
|
|
|
+import com.ym.mec.common.exception.BizException;
|
|
|
import com.ym.mec.common.page.PageInfo;
|
|
|
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.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.List;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
@RequestMapping("${app-config.url.student:}/lessonCourseware")
|
|
|
@Api(tags = "课件教材")
|
|
@@ -42,22 +45,87 @@ public class LessonCoursewareController extends BaseController {
|
|
|
@Resource
|
|
|
private CbsMusicScoreCategoriesService cbsMusicScoreCategoriesService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private CloudTeacherOrderDao cloudTeacherOrderDao;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private MemberRankCourseTypeMapperService memberRankCourseTypeMapperService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private MemberRankCategoryMapperService memberRankCategoryMapperService;
|
|
|
+
|
|
|
@ApiOperation(value = "分页查询已添加的课件")
|
|
|
@PostMapping("/queryLessonCourseware")
|
|
|
public HttpResponseResult<PageInfo<LessonCoursewareWrapper.LessonCoursewareDto>> queryLessonCourseware(@RequestBody LessonCoursewareWrapper.LessonCoursewareQuery query){
|
|
|
query.setEnable(true);
|
|
|
query.setStudentId(sysUserService.getUserId());
|
|
|
IPage<LessonCoursewareWrapper.LessonCoursewareDto> pages = lessonCoursewareService.selectPage(QueryInfo.getPage(query), query);
|
|
|
- return succeed(PageUtil.pageInfo(pages));
|
|
|
+ List<LessonCoursewareWrapper.LessonCoursewareDto> records = pages.getRecords();
|
|
|
+ if (CollectionUtils.isNotEmpty(records)) {
|
|
|
+
|
|
|
+ // 根据用户会员判断是否锁定
|
|
|
+ // 查询有效的会员
|
|
|
+ List<Integer> courseIds = getCourseIds();
|
|
|
+
|
|
|
+ // 判断曲目是否在分类中
|
|
|
+ for (LessonCoursewareWrapper.LessonCoursewareDto row : records) {
|
|
|
+ if (courseIds.contains(row.getId())) {
|
|
|
+ row.setUseStatus("UNLOCK");
|
|
|
+ } else {
|
|
|
+ row.setUseStatus("LOCK");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return succeed(PageUtil.pageInfo(pages));
|
|
|
}
|
|
|
|
|
|
@ApiOperation(value = "获取课件详情")
|
|
|
@GetMapping("/getLessonCoursewareDetail/{id}")
|
|
|
- public HttpResponseResult<CbsLessonCoursewareWrapper.LessonCourseware> getLessonCoursewareDetail(@PathVariable("id") Long id){
|
|
|
- return succeed(coursewareFeignService.lessonCoursewareDetail(id).feignData());
|
|
|
+ public HttpResponseResult<LessonCoursewareWrapper.LessonCoursewareExtend> getLessonCoursewareDetail(@PathVariable("id") Long id){
|
|
|
+ CbsLessonCoursewareWrapper.LessonCourseware lessonCourseware = coursewareFeignService.lessonCoursewareDetail(id).feignData();
|
|
|
+ if (lessonCourseware == null) {
|
|
|
+ return succeed();
|
|
|
+ }
|
|
|
+ //使用课件ID查询应用这边的ID
|
|
|
+ LessonCourseware lessonCourseware1 = lessonCoursewareService.getByLessonCoursewareId(id);
|
|
|
+ if (lessonCourseware1 == null) {
|
|
|
+ throw new BizException("课件不存在");
|
|
|
+ }
|
|
|
+
|
|
|
+ LessonCoursewareWrapper.LessonCoursewareExtend lessonCoursewareExtend = JSONObject
|
|
|
+ .parseObject(JSONObject.toJSONString(lessonCourseware), LessonCoursewareWrapper.LessonCoursewareExtend.class);
|
|
|
+ // 根据用户会员判断是否锁定
|
|
|
+ // 查询有效的会员
|
|
|
+ List<Integer> courseIds = getCourseIds();
|
|
|
+
|
|
|
+
|
|
|
+ // 判断曲目是否在分类中
|
|
|
+ if (courseIds.contains(lessonCourseware1.getId())) {
|
|
|
+ lessonCoursewareExtend.setUseStatus("UNLOCK");
|
|
|
+ } else {
|
|
|
+ lessonCoursewareExtend.setUseStatus("LOCK");
|
|
|
+ }
|
|
|
+
|
|
|
+ return succeed(lessonCoursewareExtend);
|
|
|
}
|
|
|
|
|
|
- @ApiOperation(value = "获取课件关联的课程列表")
|
|
|
+ @NotNull
|
|
|
+ private List<Integer> getCourseIds() {
|
|
|
+ List<Integer> activationVipIds = cloudTeacherOrderDao.getActivationVipIds(sysUserService.getUserId());
|
|
|
+
|
|
|
+ // 获取会员的曲目分类
|
|
|
+
|
|
|
+ List<MemberRankCourseTypeMapper> courseTypeMapperList = memberRankCourseTypeMapperService.getByMemberRankId(activationVipIds);
|
|
|
+ if (CollectionUtils.isEmpty(courseTypeMapperList)) {
|
|
|
+ courseTypeMapperList = new ArrayList<>();
|
|
|
+ }
|
|
|
+ List<Integer> categoryIds = courseTypeMapperList.stream().map(MemberRankCourseTypeMapper::getCourseType)
|
|
|
+ .distinct().map(Integer::parseInt).collect(Collectors.toList());
|
|
|
+ return categoryIds;
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "获取课件关联的课程列表")
|
|
|
@GetMapping("/getLessonCoursewareCourseList/{id}")
|
|
|
public HttpResponseResult<List<LessonCoursewareWrapper.CourseScheduleCoursewareDetail>> getLessonCoursewareCourseList(@PathVariable("id") Long id){
|
|
|
List<CbsLessonCoursewareWrapper.CourseScheduleCoursewareDetail> courseScheduleCoursewareDetails = coursewareFeignService.coursewareDetail(id).feignData();
|
|
@@ -73,9 +141,28 @@ public class LessonCoursewareController extends BaseController {
|
|
|
@GetMapping("/getLessonCourseDetail/{id}")
|
|
|
public HttpResponseResult<CbsLessonCoursewareDetailWrapper.LessonCoursewareDetail> getLessonCourseDetail(@PathVariable("id") Long id){
|
|
|
SysUser sysUser = sysUserService.getUser();
|
|
|
+ // 机构可用曲目分类
|
|
|
String teachingMaterialIds = organizationService.getTeachingMaterialIds(sysUser.getOrganId().toString(),sysUser.getTenantId());
|
|
|
List<Integer> categoryIdList = cbsMusicScoreCategoriesService.getAllCategoryIdList(teachingMaterialIds);
|
|
|
- return succeed(lessonCoursewareService.getLessonCourseDetail(id,categoryIdList));
|
|
|
+
|
|
|
+ // 学生会员可用曲目分类
|
|
|
+ Integer userId = sysUserService.getUserId();
|
|
|
+ List<Integer> activationVipIds = cloudTeacherOrderDao.getActivationVipIds(userId);
|
|
|
+
|
|
|
+ // 获取会员的曲目分类
|
|
|
+
|
|
|
+ List<MemberRankCategoryMapper> categoryMapperList = memberRankCategoryMapperService.getByMemberRankId(activationVipIds);
|
|
|
+ if (CollectionUtils.isEmpty(categoryMapperList)) {
|
|
|
+ categoryMapperList = new ArrayList<>();
|
|
|
+ }
|
|
|
+ List<Integer> categoryIds = categoryMapperList.stream().map(MemberRankCategoryMapper::getCategoryId)
|
|
|
+ .distinct().collect(Collectors.toList());
|
|
|
+ LessonCoursewareWrapper.LessonCoursewareDetailQuery query = new LessonCoursewareWrapper.LessonCoursewareDetailQuery();
|
|
|
+ query.setLessonCoursewareDetailId(id);
|
|
|
+ query.setUserType(ClientEnum.STUDENT);
|
|
|
+ query.setTenantCategoriesIdList(categoryIdList);
|
|
|
+ query.setStudentCategoriesIdList(categoryIds);
|
|
|
+ return succeed(lessonCoursewareService.getLessonCourseDetail(query));
|
|
|
}
|
|
|
|
|
|
@ApiOperation(value = "获取课件关联的声部列表")
|