mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/per-boe/java-servers.git
synced 2025-12-15 13:56:50 +08:00
Merge branch 'zcwy-0724' into dev0525
# Conflicts: # servers/boe-server-all/src/main/java/com/xboe/module/course/service/ICourseContentService.java
This commit is contained in:
@@ -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"
|
||||
|
||||
@@ -86,5 +86,5 @@ public interface ICourseContentService{
|
||||
void updateProcessVideo(String contentId, String courseId, Float processVideo);
|
||||
|
||||
|
||||
CourseContent getById(String contentId);
|
||||
|
||||
}
|
||||
|
||||
@@ -152,12 +152,6 @@ public class CourseContentServiceImpl implements ICourseContentService {
|
||||
return assess;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CourseContent getById(String contentId) {
|
||||
CourseContent courseContent = ccDao.findOne(FieldFilters.eq("id", contentId));
|
||||
return courseContent;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void updateProcessVideo(String id, String courseId, Float progressVideo) {
|
||||
|
||||
@@ -33,7 +33,7 @@ public class StudyHomeWorkApi extends ApiBaseController{
|
||||
IStudyHomeWorkService shomeworkService;
|
||||
@Resource
|
||||
private ThirdApi thirdApi;
|
||||
@PostMapping("/save")
|
||||
@PostMapping("/`save`")
|
||||
public JsonResponse<StudyHomeWork> save(@RequestBody StudyHomeWork shw, HttpServletRequest request){
|
||||
if(StringUtils.isBlank(shw.getCourseId())) {
|
||||
return badRequest("无课程信息");
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.xboe.school.study.service;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import com.xboe.school.study.entity.StudyHomeWork;
|
||||
@@ -29,4 +30,6 @@ public interface IStudyHomeWorkService {
|
||||
* @return
|
||||
*/
|
||||
List<StudyHomeWork> getByStudyIdAndContentId(String studyId,String contentId);
|
||||
|
||||
List<StudyHomeWork>getByStudnetNameAndContentId(List<String> studentName, String contentId);
|
||||
}
|
||||
|
||||
@@ -89,4 +89,9 @@ public class StudyHomeWorkServiceImpl implements IStudyHomeWorkService{
|
||||
return dao.findList(FieldFilters.eq("studyId", studyId),FieldFilters.eq("contentId", contentId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<StudyHomeWork> getByStudnetNameAndContentId(List<String> studentName, String contentId) {
|
||||
return dao.findList(FieldFilters.in("student_name", studentName),FieldFilters.eq("contentId", contentId));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user