Browse Source

Merge branch 'zx_saas_courseware_1014' of http://git.dayaedu.com/yonge/mec into test

zouxuan 4 months ago
parent
commit
8765da0c51

+ 11 - 0
mec-application/src/main/java/com/ym/mec/teacher/controller/LessonCoursewareController.java

@@ -6,6 +6,8 @@ import com.dayaedu.cbs.openfeign.client.CoursewareFeignService;
 import com.dayaedu.cbs.openfeign.wrapper.courseware.CbsLessonCoursewareDetailWrapper;
 import com.dayaedu.cbs.openfeign.wrapper.courseware.CbsLessonCoursewareWrapper;
 import com.microsvc.toolkit.common.response.paging.QueryInfo;
+import com.microsvc.toolkit.common.response.template.R;
+import com.microsvc.toolkit.config.jwt.utils.JwtUserInfo;
 import com.ym.mec.auth.api.entity.SysUser;
 import com.ym.mec.biz.dal.dao.TeacherDao;
 import com.ym.mec.biz.dal.entity.Subject;
@@ -23,7 +25,9 @@ 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.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.*;
+import springfox.documentation.annotations.ApiIgnore;
 
 import javax.annotation.Resource;
 import java.util.ArrayList;
@@ -98,4 +102,11 @@ public class LessonCoursewareController extends BaseController {
 	public HttpResponseResult<List<Subject>> getLessonCoursewareSubjectList(){
 		return succeed(lessonCoursewareService.getDao().getLessonCoursewareSubjectList());
 	}
+
+	@ApiOperation(value = "关联课程类型")
+	@PostMapping("/refLevel")
+	public HttpResponseResult<List<LessonCoursewareWrapper.RefLevelDetailInfo>> refLevel(@RequestBody LessonCoursewareWrapper.RefLevelQuery query) {
+		query.setTeacherId(sysUserService.getUserId());
+		return succeed(lessonCoursewareService.refLevel(query));
+	}
 }

+ 40 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/wrapper/LessonCoursewareWrapper.java

@@ -51,6 +51,9 @@ public class LessonCoursewareWrapper {
         private Integer teacherId;
 
         private Integer studentId;
+
+        @ApiModelProperty("课程级别")
+        private Integer level;
     }
 
     @Data
@@ -82,6 +85,9 @@ public class LessonCoursewareWrapper {
         @ApiModelProperty("声部id")
         private Integer subjectId;
 
+        @ApiModelProperty("课程级别")
+        private Integer level;
+
         @ApiModelProperty(value = "学员适用范围ALL,RANGE,DISABLE")
         private String studentRangeType;
 
@@ -185,4 +191,38 @@ public class LessonCoursewareWrapper {
         private List<SimpleUserDto> teacherList;
     }
 
+    @Data
+    public static class RefLevelDetailInfo{
+        @ApiModelProperty("课件ID")
+        private String id;
+
+        @ApiModelProperty("教材ID")
+        private Long lessonCoursewareId;
+        @ApiModelProperty("教材名称")
+        private String lessonCoursewareName;
+
+        @ApiModelProperty("封面")
+        private String coverImg;
+
+        @ApiModelProperty("课程类型")
+        private String courseTypeCode;
+
+        @ApiModelProperty("是否锁定")
+        private Boolean lockFlag;
+
+        @ApiModelProperty("是否当前使用")
+        private Boolean useFlag;
+
+    }
+
+    @Data
+    public static class RefLevelQuery {
+
+        @ApiModelProperty(value = "课件详情ID",required = true)
+        private String lessonCoursewareDetailId;
+
+        @ApiModelProperty(value = "老师ID",hidden = true)
+        private Integer teacherId;
+    }
+
 }

+ 2 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/LessonCoursewareService.java

@@ -23,5 +23,7 @@ public interface LessonCoursewareService extends IService<LessonCourseware> {
     LessonCoursewareWrapper.UpdateRangeDetail getRangeType(Integer lessonCoursewareId);
 
     CbsLessonCoursewareDetailWrapper.LessonCoursewareDetail getLessonCourseDetail(Long id,List<Integer> categoryIdList);
+
+    List<LessonCoursewareWrapper.RefLevelDetailInfo> refLevel(LessonCoursewareWrapper.RefLevelQuery query);
 }
 

+ 76 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/LessonCoursewareServiceImpl.java

@@ -14,6 +14,7 @@ import com.ym.mec.biz.dal.dto.SimpleUserDto;
 import com.ym.mec.biz.dal.entity.LessonCourseware;
 import com.ym.mec.biz.dal.entity.LessonCoursewareUserMapper;
 import com.ym.mec.biz.dal.entity.SysMusicScore;
+import com.ym.mec.biz.dal.entity.Teacher;
 import com.ym.mec.biz.dal.mapper.LessonCoursewareMapper;
 import com.ym.mec.biz.dal.wrapper.LessonCoursewareWrapper;
 import com.ym.mec.biz.service.LessonCoursewareService;
@@ -64,6 +65,7 @@ public class LessonCoursewareServiceImpl extends ServiceImpl<LessonCoursewareMap
                 List<Long> lessonCoursewareIds = dtos.stream().map(LessonCoursewareWrapper.LessonCoursewareDto::getLessonCoursewareId).collect(Collectors.toList());
                 CbsLessonCoursewareWrapper.LambdaQuery lambdaQuery = new CbsLessonCoursewareWrapper.LambdaQuery();
                 lambdaQuery.setIds(lessonCoursewareIds);
+                lambdaQuery.setLevel(query.getLevel());
                 lambdaQuery.setName(query.getSearch());
                 List<CbsLessonCoursewareWrapper.Entity> entityList = coursewareFeignService.lessonCoursewareLambdaQuery(lambdaQuery).feignData();
                 if(CollectionUtils.isNotEmpty(entityList)){
@@ -106,6 +108,7 @@ public class LessonCoursewareServiceImpl extends ServiceImpl<LessonCoursewareMap
                     e.setName(entity.getName());
                     e.setCover(entity.getCoverImg());
                     e.setCourseNum(entity.getCourseNum());
+                    e.setLevel(entity.getLevel());
                 }
             }
         }
@@ -201,6 +204,79 @@ public class LessonCoursewareServiceImpl extends ServiceImpl<LessonCoursewareMap
         return detail;
     }
 
+    @Override
+    public List<LessonCoursewareWrapper.RefLevelDetailInfo> refLevel(LessonCoursewareWrapper.RefLevelQuery query) {
+        List<LessonCoursewareWrapper.RefLevelDetailInfo> result = new ArrayList<>();
+        CbsLessonCoursewareDetailWrapper.LessonCoursewareDetail lessonCoursewareDetail =
+                coursewareFeignService.lessonCoursewareDetailDetail(Long.parseLong(query.getLessonCoursewareDetailId())).feignData();
+        if (lessonCoursewareDetail == null) {
+            throw new BizException("课件未找到");
+        }
+        Teacher teacher = teacherDao.get(query.getTeacherId());
+        if (teacher == null) {
+            throw new BizException("老师信息不存在");
+        }
+        if (lessonCoursewareDetail.getLevel() == null || teacher.getCoursewareFlag()) {
+            return new ArrayList<>();
+        }
+        LessonCoursewareWrapper.LessonCoursewareQuery query1 = new LessonCoursewareWrapper.LessonCoursewareQuery();
+        query1.setPage(1);
+        query1.setRows(9999);
+        query1.setTeacherId(query.getTeacherId());
+        query1.setEnable(true);
+        List<LessonCoursewareWrapper.LessonCoursewareDto> dtos = baseMapper.list(query1);
+        if(CollectionUtils.isEmpty(dtos)){
+            return new ArrayList<>();
+        }
+        List<Long> lessonCoursewareIds = dtos.stream().map(LessonCoursewareWrapper.LessonCoursewareDto::getLessonCoursewareId).collect(Collectors.toList());
+        CbsLessonCoursewareWrapper.LessonCourseware lessonCourseware =
+                coursewareFeignService.lessonCoursewareDetail(lessonCoursewareDetail.getLessonCoursewareId()).feignData();
+        if (lessonCourseware == null) {
+            throw new BizException("课件未找到");
+        }
+        // 查询当前能使用的课件
+        CbsLessonCoursewareWrapper.LessonCoursewareQuery lambdaQuery = new CbsLessonCoursewareWrapper.LessonCoursewareQuery();
+        lambdaQuery.setPage(1);
+        lambdaQuery.setRows(9999);
+        lambdaQuery.setLevel(lessonCourseware.getLevel());
+        lambdaQuery.setOrchestraType(lessonCourseware.getOrchestraType());
+        lambdaQuery.setLessonCoursewareIds(lessonCoursewareIds);
+        List<CbsLessonCoursewareWrapper.LessonCourseware> lessonCoursewareList = coursewareFeignService.lessonCoursewarePage(lambdaQuery).feignData().getRows();
+        if (CollectionUtils.isEmpty(lessonCoursewareList)) {
+            return new ArrayList<>();
+        }
+        List<Long> courseIds = lessonCoursewareList.stream().map(CbsLessonCoursewareWrapper.LessonCourseware::getId).collect(Collectors.toList());
+        Map<Long, CbsLessonCoursewareWrapper.LessonCourseware> lessonCoursewareMap =
+                lessonCoursewareList.stream().collect(Collectors.toMap(CbsLessonCoursewareWrapper.LessonCourseware::getId, o -> o));
+
+        // 查询可用的课件详情信息
+        CbsLessonCoursewareDetailWrapper.LessonCoursewareDetailQuery lessonCoursewareDetailQuery = new CbsLessonCoursewareDetailWrapper.LessonCoursewareDetailQuery();
+        lessonCoursewareDetailQuery.setPage(1);
+        lessonCoursewareDetailQuery.setRows(9999);
+        lessonCoursewareDetailQuery.setLessonCoursewareIdList(courseIds);
+        lessonCoursewareDetailQuery.setLevel(lessonCoursewareDetail.getLevel());
+        List<CbsLessonCoursewareDetailWrapper.LessonCoursewareDetail> lessonCoursewareDetails = coursewareFeignService.lessonCoursewareDetailPage(lessonCoursewareDetailQuery).feignData().getRows();
+        if (CollectionUtils.isEmpty(lessonCoursewareDetails)) {
+            return new ArrayList<>();
+        }
+        for (CbsLessonCoursewareDetailWrapper.LessonCoursewareDetail coursewareDetail : lessonCoursewareDetails) {
+            LessonCoursewareWrapper.RefLevelDetailInfo refLevelDetailInfo = new LessonCoursewareWrapper.RefLevelDetailInfo();
+            refLevelDetailInfo.setId(coursewareDetail.getId());
+            refLevelDetailInfo.setLessonCoursewareId(coursewareDetail.getLessonCoursewareId());
+            CbsLessonCoursewareWrapper.LessonCourseware lessonCourseware1 = lessonCoursewareMap.get(coursewareDetail.getLessonCoursewareId());
+            if (lessonCourseware1 == null) {
+                continue;
+            }
+            refLevelDetailInfo.setCoverImg(lessonCourseware1.getCoverImg());
+            refLevelDetailInfo.setCourseTypeCode(lessonCourseware1.getCourseTypeCode());
+            refLevelDetailInfo.setLockFlag(false);
+            refLevelDetailInfo.setLessonCoursewareName(lessonCourseware1.getName());
+            refLevelDetailInfo.setUseFlag(coursewareDetail.getId().equals(query.getLessonCoursewareDetailId()));
+            result.add(refLevelDetailInfo);
+        }
+        return result;
+    }
+
     //递归处理CbsLessonCoursewareDetailWrapper.KnowledgePointSmall
     private void setTreeResourceId(List<CbsLessonCoursewareDetailWrapper.KnowledgePointSmall> knowledgePointList,List<Integer> categoryIdList){
         if(CollectionUtils.isNotEmpty(knowledgePointList)){

+ 1 - 1
pom.xml

@@ -26,7 +26,7 @@
 		<docker.registry.repository>127.0.0.1:5000</docker.registry.repository>
 		<docker.maven.plugin.version>1.2.2</docker.maven.plugin.version>
 		<com.microsvc.toolkit.version>1.0.8-RC1</com.microsvc.toolkit.version>
-		<cbs.version>1.0.16</cbs.version>
+		<cbs.version>1.0.19</cbs.version>
 	</properties>
 
 	<dependencyManagement>