在线课固定时长问题修改

This commit is contained in:
zhaolongfei
2024-07-09 09:47:36 +08:00
parent d90f4d883f
commit 3116bed63c

View File

@@ -7,9 +7,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
@@ -238,7 +236,6 @@ public class CourseFileApi extends ApiBaseController {
file.setDeleted(false);
file.setDown(true);//默认允许下载
file.setDuration(0);
if (file.getResType() == null) {
if ("mp4".indexOf(file.getFileType()) > -1) {
file.setResType(10);//以后换成变量
@@ -263,6 +260,22 @@ public class CourseFileApi extends ApiBaseController {
file.setResType(90);//以后换成变量
}
}
if (file.getResType() != null) {
if ("jpg,png,gif".indexOf(file.getFileType()) > -1) {
if (file.getDuration() != null) {
file.setDuration(file.getDuration() * 60);
}
}else if ("doc,xls,ppt,docx,xlsx,pptx".indexOf(file.getFileType()) > -1) {
if (file.getDuration() != null) {
file.setDuration(file.getDuration() * 60);
}
} else if (file.getFileType().equalsIgnoreCase("zip")) {
file.setResType(BoedxCourseFileType.Scrom.getValue());//scorm课件
if (file.getDuration() != null) {
file.setDuration(file.getDuration() * 60);
}
}
}
String fileFullPath = SysConstant.getConfigValue(BaseConstant.CONFIG_UPLOAD_FILES_SAVEPATH) + file.getFilePath();
if ("mp3,mp4".indexOf(file.getFileType()) > -1){
log.info("上传 "+file.getFileType()+"文件:"+file.getFilePath());
@@ -293,27 +306,18 @@ public class CourseFileApi extends ApiBaseController {
}
try {
Set<String> officeFileTypes = new HashSet<>(Arrays.asList("doc", "xls", "ppt", "docx", "xlsx", "pptx"));
file.setFileType(file.getFileType());
if(file.getFileType().equalsIgnoreCase("pdf")) {
file.setPreviewFilePath(file.getFilePath());
if (file.getDuration()!=null){
file.setDuration(file.getDuration()*60);
}
file.setConverStatus(0);//代表不需要转化
}else if ("doc,xls,ppt,docx,xlsx,pptx".indexOf(file.getFileType().toLowerCase()) > -1) {
}else if (officeFileTypes.contains(file.getFileType().toLowerCase())) {
file.setConverStatus(1);//转化中
if (file.getDuration()!=null){
file.setDuration(file.getDuration()*60);
}
}else if(file.getFileType().equalsIgnoreCase("zip")) {
//scorm包的内容
try {
SCORMParser scormParser=new SCORMParser();
String json = scormParser.parserToJson(fileFullPath);
if (file.getDuration()!=null){
file.setDuration(file.getDuration()*60);
}
file.setContent(json);
}catch (Exception e) {
log.error("上传的非scorm课件的zip文件", e);