diff --git a/servers/boe-server-all/src/main/java/com/xboe/module/course/api/CourseFileApi.java b/servers/boe-server-all/src/main/java/com/xboe/module/course/api/CourseFileApi.java index f59fd1d1..ac52d43c 100644 --- a/servers/boe-server-all/src/main/java/com/xboe/module/course/api/CourseFileApi.java +++ b/servers/boe-server-all/src/main/java/com/xboe/module/course/api/CourseFileApi.java @@ -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 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);