|
|
|
|
@@ -29,6 +29,8 @@ import com.xboe.module.course.dao.CourseSectionDao;
|
|
|
|
|
import com.xboe.module.course.entity.*;
|
|
|
|
|
import com.xboe.module.course.vo.TeacherVo;
|
|
|
|
|
import com.xboe.module.usergroup.entity.UserGroupItem;
|
|
|
|
|
import com.xboe.school.study.entity.StudyHomeWork;
|
|
|
|
|
import com.xboe.school.study.service.IStudyHomeWorkService;
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.data.redis.core.StringRedisTemplate;
|
|
|
|
|
@@ -97,17 +99,8 @@ public class CoursePortalApi extends ApiBaseController{
|
|
|
|
|
@Resource
|
|
|
|
|
private ThirdApi thirdApi;
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private CourseHomeWorkDao homeworkDao;
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private CourseContentDao ccDao;
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private CourseSectionDao courseSectionDao;
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private CourseDao courseDao;
|
|
|
|
|
@Autowired
|
|
|
|
|
IStudyHomeWorkService shomeworkService;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
StringRedisTemplate redisTemplate;
|
|
|
|
|
@@ -369,35 +362,43 @@ public class CoursePortalApi extends ApiBaseController{
|
|
|
|
|
}
|
|
|
|
|
//作业导出
|
|
|
|
|
@GetMapping("/export")
|
|
|
|
|
public void export(String contentId, String courseName,HttpServletResponse response) throws IOException {
|
|
|
|
|
//将courseId以逗号分割转换为list
|
|
|
|
|
List<String> contentIds = Arrays.asList(contentId.split(","));
|
|
|
|
|
public void export(String contentId, String courseName,String studentName,HttpServletResponse response) throws IOException {
|
|
|
|
|
// 将courseId以逗号分割转换为list
|
|
|
|
|
List<String> studentNames = Arrays.asList(studentName.split(","));
|
|
|
|
|
Map<String, String>map=new HashMap<>();
|
|
|
|
|
try {
|
|
|
|
|
homeworkDao.findList(FieldFilters.in("content_id", contentIds)).stream().filter(Objects::nonNull).forEach(e -> {
|
|
|
|
|
//查询内容名称
|
|
|
|
|
CourseContent courseContent=contentService.getById(e.getContentId());
|
|
|
|
|
if(courseContent!=null &&courseContent.getContentName()==null){
|
|
|
|
|
courseContent.setContentName("作业");
|
|
|
|
|
}
|
|
|
|
|
//查询目录
|
|
|
|
|
List<CourseSection> courseSections = sectionService.getByCourseId(e.getCourseId());
|
|
|
|
|
// homeworkDao.findList(FieldFilters.in("content_id", contentIds)).stream().filter(Objects::nonNull).forEach(e -> {
|
|
|
|
|
// //查询内容名称
|
|
|
|
|
// CourseContent courseContent=contentService.getById(e.getContentId());
|
|
|
|
|
// if(courseContent!=null &&courseContent.getContentName()==null){
|
|
|
|
|
// courseContent.setContentName("作业");
|
|
|
|
|
// }
|
|
|
|
|
// //查询目录
|
|
|
|
|
// List<CourseSection> courseSections = sectionService.getByCourseId(e.getCourseId());
|
|
|
|
|
// //取作业后缀名
|
|
|
|
|
// int dotIndex = e.getFile().lastIndexOf('.'); // 查找最后一个'.'的位置
|
|
|
|
|
// String extension = e.getFile().substring(dotIndex);
|
|
|
|
|
// //判断是否有目录
|
|
|
|
|
// if(!courseSections.isEmpty()){
|
|
|
|
|
// map.put(courseSections.get(0).getName()+"--"+courseContent.getContentName()+extension, "/home/www/elearning/upload"+e.getFile());
|
|
|
|
|
// }else {
|
|
|
|
|
// Course course=courseDao.get(e.getCourseId());
|
|
|
|
|
// if(course==null || course.getDeleted()){
|
|
|
|
|
// throw new RuntimeException("课程不存在或已被删除");
|
|
|
|
|
// }
|
|
|
|
|
// map.put(course.getName()+"--"+courseContent.getContentName()+extension, "/home/www/elearning/upload"+e.getFile());
|
|
|
|
|
// }
|
|
|
|
|
// });
|
|
|
|
|
shomeworkService.getByStudnetNameAndContentId(studentNames,contentId).stream().filter(Objects::nonNull).filter(e->e.getFilePath()!=null).forEach(e->{
|
|
|
|
|
//取作业后缀名
|
|
|
|
|
int dotIndex = e.getFile().lastIndexOf('.'); // 查找最后一个'.'的位置
|
|
|
|
|
String extension = e.getFile().substring(dotIndex);
|
|
|
|
|
//判断是否有目录
|
|
|
|
|
if(!courseSections.isEmpty()){
|
|
|
|
|
map.put(courseSections.get(0).getName()+"--"+courseContent.getContentName()+extension, "/home/www/elearning/upload"+e.getFile());
|
|
|
|
|
}else {
|
|
|
|
|
Course course=courseDao.get(e.getCourseId());
|
|
|
|
|
if(course==null || course.getDeleted()){
|
|
|
|
|
throw new RuntimeException("课程不存在或已被删除");
|
|
|
|
|
}
|
|
|
|
|
map.put(course.getName()+"--"+courseContent.getContentName()+extension, "/home/www/elearning/upload"+e.getFile());
|
|
|
|
|
}
|
|
|
|
|
int dotIndex = e.getFilePath().lastIndexOf('/'); // 查找最后一个'.'的位置
|
|
|
|
|
String extension = e.getFilePath().substring(dotIndex+1);
|
|
|
|
|
map.put(extension,e.getFilePath());
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
throw new RuntimeException("导出异常");
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
throw new RuntimeException("导出异常"+e.getMessage());
|
|
|
|
|
}
|
|
|
|
|
String encodedFilename = URLEncoder.encode(courseName+"【作业】.zip")
|
|
|
|
|
.replace("+", "%20") // 空格替换为"%20"
|
|
|
|
|
|