diff --git a/src/main/java/com/fjy/spring/controller/DownLoadController.java b/src/main/java/com/fjy/spring/controller/DownLoadController.java index ed47bfe..1602549 100644 --- a/src/main/java/com/fjy/spring/controller/DownLoadController.java +++ b/src/main/java/com/fjy/spring/controller/DownLoadController.java @@ -42,31 +42,31 @@ public class DownLoadController { return "download/dodownload"; }*/ - @GetMapping("/download/findall") + @GetMapping("/home/admin/download/findall") @ResponseBody - public List toDownloadAll(){ + public List toDownloadAll() { List files = fileService.findAllFile();//此处做空指针判断并抛出错误 - if (files!=null) + if (files != null) return files; new UserException(ResultEnum.EMPTY_DATA); return null; } - @GetMapping("/download/findone") + @GetMapping("/home/download/findone") @ResponseBody - public List toDownloadOne(){ - TbUser user = (TbUser)request.getSession().getAttribute(USER_SESSION_KEY); + public List toDownloadOne() { + TbUser user = (TbUser) request.getSession().getAttribute(USER_SESSION_KEY); //log.info(user.toString()); List files = fileService.findByColuserid(user.getColuserid()); //此处做空指针判断并抛出错误 - if (files!=null) + if (files != null) return files; new UserException(ResultEnum.EMPTY_DATA); return null; } - @RequestMapping("/download/dodownload") - public String download(@RequestParam Integer fileId , HttpServletRequest request, HttpServletResponse response){ + @RequestMapping("/home/download/dodownload") + public String download(@RequestParam Integer fileId, HttpServletRequest request, HttpServletResponse response) { response.setContentType("text/html;charset=utf-8"); try { @@ -124,16 +124,17 @@ public class DownLoadController { /** * 传入课程名和文件夹名称,打包下载目录下所有文件 + * * @param courseName * @param folder * @param response */ - @GetMapping("/download/downloadzip") + @GetMapping("/home/admin/download/downloadzip") public void batDownload(@RequestParam(value = "courseName") String courseName, - @RequestParam(value = "Folder")String folder, HttpServletResponse response){ + @RequestParam(value = "Folder") String folder, HttpServletResponse response) { //获取文件夹名称 - String paths = serverProperties.getFilePath()+ "upload/"+courseName+"/"+folder; - String zipPath = serverProperties.getFilePath()+"zip/"; + String paths = serverProperties.getFilePath() + "upload/" + courseName + "/" + folder; + String zipPath = serverProperties.getFilePath() + "zip/"; File dir = new File(zipPath); if (!dir.exists()) { @@ -141,12 +142,12 @@ public class DownLoadController { } List pathList = new ArrayList(); - pathList=getFileString(paths); + pathList = getFileString(paths); //需要压缩的文件--包括文件地址和文件名 - String []path =(String[])pathList.toArray(new String[0]); + String[] path = (String[]) pathList.toArray(new String[0]); // 要生成的压缩文件地址和文件名称 - String zipFileName=courseName+folder+".zip"; - String desPath = zipPath+"\\"+zipFileName; + String zipFileName = courseName + folder + ".zip"; + String desPath = zipPath + "\\" + zipFileName; //System.out.println("打包文件存储地址:"+desPath); File zipFile = new File(desPath); @@ -156,24 +157,25 @@ public class DownLoadController { try { //构造最终压缩包的输出流 zipStream = new ZipOutputStream(new FileOutputStream(zipFile)); - for(int i =0;i path = new ArrayList(); List name = new ArrayList(); - int i = 0,j=0; + int i = 0, j = 0; if (files == null) {// 如果目录为空,直接退出 path.add("空目录"); return path; diff --git a/src/main/java/com/fjy/spring/interceptor/WebAppConfig.java b/src/main/java/com/fjy/spring/interceptor/WebAppConfig.java index 5c000e8..5d20a5e 100644 --- a/src/main/java/com/fjy/spring/interceptor/WebAppConfig.java +++ b/src/main/java/com/fjy/spring/interceptor/WebAppConfig.java @@ -6,7 +6,7 @@ import org.springframework.web.servlet.config.annotation.PathMatchConfigurer; import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; -/*@Configuration*/ +@Configuration public class WebAppConfig implements WebMvcConfigurer { /** diff --git a/src/main/resources/static/js/admin.js b/src/main/resources/static/js/admin.js index 4be07a0..72bc3d2 100644 --- a/src/main/resources/static/js/admin.js +++ b/src/main/resources/static/js/admin.js @@ -62,7 +62,7 @@ var Main = { }, methods: { uploadURL(row) { - return getRootPath_web()+"/moreUpload?rename=false"; + return getRootPath_web()+"/home/moreUpload?rename=false"; }, submitUpload() { this.$refs.upload.submit(); diff --git a/src/main/resources/static/js/homepage.js b/src/main/resources/static/js/homepage.js index 3d5271a..0566ed8 100644 --- a/src/main/resources/static/js/homepage.js +++ b/src/main/resources/static/js/homepage.js @@ -200,7 +200,7 @@ var Main = { methods: { getFileList(){ let that = this; - axios.get(getRootPath_web()+'/download/findone') + axios.get(getRootPath_web()+'/home/download/findone') .then(function (response) { //console.log(response.data); that.DownloadList = response.data; @@ -230,7 +230,7 @@ var Main = { }); }, uploadURL(row) { - return getRootPath_web()+"/moreUpload?courseName=" + row.coursename + "&folder=" + row.workfolder+"&rename=true"; + return getRootPath_web()+"/home/moreUpload?courseName=" + row.coursename + "&folder=" + row.workfolder+"&rename=true"; }, limitTime(row) { return DateDiff(row.worktime.replace(/([^\s]+)\s.*/, "$1"), cur); @@ -300,7 +300,7 @@ var Main = { }, handleDownload(row) { /*var url = window.location.protocol+"://"+window.location.host+":"+window.location.port+"/"*/ - window.open(getRootPath_web()+"/download/dodownload?fileId=" + row.colfileid); + window.open(getRootPath_web()+"/home/download/dodownload?fileId=" + row.colfileid); }, handleDelete(row) { let that = this; diff --git a/src/main/resources/static/js/homework.js b/src/main/resources/static/js/homework.js index 8029df4..4d3ce4b 100644 --- a/src/main/resources/static/js/homework.js +++ b/src/main/resources/static/js/homework.js @@ -51,14 +51,6 @@ var Main = { .catch(function (error) { console.log(error); }); - axios.get(getRootPath_web()+'/home/findallvhomework') - .then(function (response) { - console.log(response.data); - that.homeworkData = response.data; - }) - .catch(function (error) { - console.log(error); - }); }) }, methods: { @@ -111,7 +103,7 @@ var Main = { }, handleDownload(row) { /*var url = window.location.protocol+"://"+window.location.host+":"+window.location.port+"/"*/ - window.open(getRootPath_web()+"/download/downloadzip?courseName=" + window.open(getRootPath_web()+"/home/admin/download/downloadzip?courseName=" + row.courseName+"&Folder="+row.folder); }, handleSelect(key, keyPath) {