导入课程

beetlsql3-dev
Mlxa0324 2 years ago
parent eb59d92734
commit b4076b046a

@ -21,7 +21,7 @@ public class TeacherOpenCourseMergeResourcesInfo extends BaseEntity{
private Long teacherOpenCourseMergeResourcesInfoId ;
//开课课程ID
@Dict(type="teacher_open_course_merge_course_info.course_info_name.course_info_status=1")
@Dict(type="TEACHER_OPEN_COURSE_MERGE_COURSE_INFO.course_info_name.course_info_status=1")
private Long courseInfoId ;

@ -239,6 +239,7 @@ public class CourseInfoService extends CoreBaseService<CourseInfo>{
/**
* ID
*
*
* @param courseInfoId ID
* @return
@ -385,6 +386,13 @@ public class CourseInfoService extends CoreBaseService<CourseInfo>{
return courseInfos;
}
/**
* IDID
*
*
* @param courseInfoId
* @return
*/
public List<CourseInfo> getCourseResources (Long courseInfoId){
List<CourseInfo> courseInfoList = new ArrayList<>();

@ -1,6 +1,9 @@
package com.ibeetl.jlw.service;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.jlw.util.ToolUtils;
import com.alibaba.fastjson.JSON;
@ -397,8 +400,8 @@ public class TeacherOpenCourseMergeCourseInfoService extends CoreBaseService<Tea
* -
*
*
* @param courseInfoIds ID
* @param teacherOpenCourseId iD
* @param courseInfoIds ID
* @param teacherOpenCourseId ID
* @return
*/
public void copyFromCourseInfo(@NotEmpty(message = "系统课程ID不能为空") Set<Long> courseInfoIds,
@ -406,14 +409,23 @@ public class TeacherOpenCourseMergeCourseInfoService extends CoreBaseService<Tea
// 开启并行处理
courseInfoIds.stream().parallel().forEach(courseInfoId -> {
List<CourseInfo> chapterList = courseInfoService.getChapterList(courseInfoId);
// 当前的课程信息
CourseInfo currentCourseInfo = courseInfoService.getById(courseInfoId);
// 查询当前课程信息下的,章节或者小节信息,返回一维集合
List<CourseInfo> chapterList = courseInfoService.getCourseResources(courseInfoId);
// 将课程本身添加进集合
chapterList.add(currentCourseInfo);
// 拷贝
CopyOptions copyOptions = CopyOptions.create().setFieldMapping(MapUtil.of("courseInfoId", "teacherOpenCourseMergeCourseInfoId"));
List<TeacherOpenCourseMergeCourseInfo> copyToList =
BeanUtil.copyToList(chapterList, TeacherOpenCourseMergeCourseInfo.class);
BeanUtil.copyToList(chapterList, TeacherOpenCourseMergeCourseInfo.class, copyOptions);
if (ObjectUtil.isEmpty(copyToList)) { return; }
// 设置开课ID
copyToList.forEach(item -> item.setTeacherOpenCourseId(teacherOpenCourseId));
copyToList.forEach(item -> {
item.setTeacherOpenCourseId(teacherOpenCourseId);
item.setCourseInfoName(item.getCourseInfoName().replaceAll("&nbsp;", ""));
});
// 批量插入
teacherOpenCourseMergeCourseInfoDao.insertBatch(copyToList);
});
@ -438,12 +450,13 @@ public class TeacherOpenCourseMergeCourseInfoService extends CoreBaseService<Tea
courseInfoIds.stream().parallel().forEach(courseInfoId -> {
// 获取这个课程章节下的所有的子章节信息
List<CourseInfo> chapterList = courseInfoService.getChapterList(Long.valueOf(courseInfoId));
HashSet<CourseInfo> courseInfos = CollectionUtil.newHashSet(chapterList);
// 如果课程章节没查到记录,则下面的资源也没必要执行,资源依赖课程章节
if (ObjectUtil.isEmpty(chapterList)) { return; }
if (ObjectUtil.isEmpty(courseInfos)) { return; }
// 取出来所有的课程章节ID
String allCourseInfoIdsJoin = chapterList.stream().map(item -> item.getCourseInfoId().toString()).collect(joining(","));
String allCourseInfoIdsJoin = courseInfos.stream().map(item -> item.getCourseInfoId().toString()).collect(joining(","));
ResourcesQuestionQuery resourcesQuestionQuery = new ResourcesQuestionQuery();
resourcesQuestionQuery.setCourseInfoIds(allCourseInfoIdsJoin);

@ -378,7 +378,7 @@ public class TeacherOpenCourseMergeResourcesQuestionService extends CoreBaseServ
if (ObjectUtil.isEmpty(resourcesQuestionIds)) { return; }
// 题目ID集合
String ids = join(resourcesQuestionIds, ",");
String ids = join(resourcesQuestionIds.toArray(), ",");
List<ResourcesQuestion> resourcesQuestions = resourcesQuestionDao.getByIds(ids);
// 拷贝

@ -1,5 +1,6 @@
package com.ibeetl.jlw.web;
import cn.hutool.core.collection.CollectionUtil;
import cn.jlw.Interceptor.GetFile;
import cn.jlw.Interceptor.RFile;
import cn.jlw.Interceptor.SCoreUser;
@ -39,7 +40,6 @@ import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
* - -线
@ -439,8 +439,8 @@ public class TeacherOpenCourseMergeCourseInfoController{
* @return
*/
@PostMapping(API + "/copyFromCourseInfo.do")
public JsonResult copyFromCourseInfo(Set<Long> courseInfoIds, Long teacherOpenCourseId) {
teacherOpenCourseMergeCourseInfoService.copyFromCourseInfo(courseInfoIds, teacherOpenCourseId);
public JsonResult copyFromCourseInfo(Long[] courseInfoIds, Long teacherOpenCourseId) {
teacherOpenCourseMergeCourseInfoService.copyFromCourseInfo(CollectionUtil.newHashSet(courseInfoIds), teacherOpenCourseId);
return JsonResult.success();
}
@ -455,8 +455,8 @@ public class TeacherOpenCourseMergeCourseInfoController{
* @return
*/
@PostMapping(API + "/importCourseInfo.do")
public JsonResult importCourseInfo(Set<Long> courseInfoIds, Long teacherOpenCourseId) {
teacherOpenCourseMergeCourseInfoService.importCourseInfo(courseInfoIds, teacherOpenCourseId);
public JsonResult importCourseInfo(Long[] courseInfoIds, Long teacherOpenCourseId) {
teacherOpenCourseMergeCourseInfoService.importCourseInfo(CollectionUtil.newHashSet(courseInfoIds), teacherOpenCourseId);
return JsonResult.success();
}

@ -1,5 +1,6 @@
package com.ibeetl.jlw.web;
import cn.hutool.core.collection.CollectionUtil;
import cn.jlw.Interceptor.GetFile;
import cn.jlw.Interceptor.RFile;
import cn.jlw.Interceptor.SCoreUser;
@ -39,7 +40,6 @@ import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
* -
@ -412,8 +412,8 @@ public class TeacherOpenCourseMergeResourcesInfoController{
* @return
*/
@PostMapping(API + "/copyFromResourcesInfo.do")
public JsonResult copyFromResourcesInfo(Set<Long> resourcesInfoIds, Long teacherOpenCourseId) {
teacherOpenCourseMergeResourcesInfoService.copyFromResourcesInfo(resourcesInfoIds, teacherOpenCourseId);
public JsonResult copyFromResourcesInfo(Long[] resourcesInfoIds, Long teacherOpenCourseId) {
teacherOpenCourseMergeResourcesInfoService.copyFromResourcesInfo(CollectionUtil.newHashSet(resourcesInfoIds), teacherOpenCourseId);
return JsonResult.success();
}
}

@ -1,5 +1,6 @@
package com.ibeetl.jlw.web;
import cn.hutool.core.collection.CollectionUtil;
import cn.jlw.Interceptor.GetFile;
import cn.jlw.Interceptor.RFile;
import cn.jlw.Interceptor.SCoreUser;
@ -39,7 +40,6 @@ import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
* --线
@ -427,8 +427,8 @@ public class TeacherOpenCourseMergeResourcesQuestionController{
* @return
*/
@PostMapping(API + "/copyFromQuestion.do")
public JsonResult copyFromQuestion(Set<Long> resourcesQuestionIds, Long teacherOpenCourseId) {
teacherOpenCourseMergeResourcesQuestionService.copyFromQuestion(resourcesQuestionIds, teacherOpenCourseId);
public JsonResult copyFromQuestion(Long[] resourcesQuestionIds, Long teacherOpenCourseId) {
teacherOpenCourseMergeResourcesQuestionService.copyFromQuestion(CollectionUtil.newHashSet(resourcesQuestionIds), teacherOpenCourseId);
return JsonResult.success();
}

Loading…
Cancel
Save