diff --git a/pom.xml b/pom.xml index 357ec3c..6ce8b4d 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ com.fjy spring - V2.6.8 + V2.7 jar spring diff --git a/src/main/java/com/fjy/spring/controller/DataController.java b/src/main/java/com/fjy/spring/controller/DataController.java index 0acfd1b..8c947b2 100644 --- a/src/main/java/com/fjy/spring/controller/DataController.java +++ b/src/main/java/com/fjy/spring/controller/DataController.java @@ -56,82 +56,83 @@ public class DataController { private HttpServletRequest httpServletRequest; @GetMapping("/home/findAllHomework") - public List findAllHomework(){ + public List findAllHomework() { List homeworks = workDetailService.findAll(); - if (homeworks!=null){ + if (homeworks != null) { return homeworks; } throw new UserException(ResultEnum.EMPTY_DATA); } @GetMapping("/home/findvlog") - public List findlog(){ + public List findlog() { List vlogs = logService.findvlog(); - if (vlogs!=null){ + if (vlogs != null) { return vlogs; } throw new UserException(ResultEnum.EMPTY_DATA); } @GetMapping("/home/admin/findvfeedback") - public List findAllVFeedback(){ + public List findAllVFeedback() { List feedBacks = feedBackService.findAllVFeedback(); - if (feedBacks!=null){ + if (feedBacks != null) { return feedBacks; } throw new UserException(ResultEnum.EMPTY_DATA); } @GetMapping("/home/findvcourse") - public List findVCourse(){ + public List findVCourse() { List vCourses = courseService.findAllVCourse(); - if (vCourses!=null){ + if (vCourses != null) { return vCourses; } throw new UserException(ResultEnum.EMPTY_DATA); } @GetMapping("/home/admin/findalluser") - public List findAllUser(){ + public List findAllUser() { List users = userService.findAllUser(); - if (users!=null){ + if (users != null) { return users; } throw new UserException(ResultEnum.EMPTY_DATA); } @GetMapping("/home/findallvhomework") - public List findAllVHomework(){ + public List findAllVHomework() { List vHomeworks = homeworkService.findAllVHomework(); - if (vHomeworks!=null){ + if (vHomeworks != null) { return vHomeworks; } throw new UserException(ResultEnum.EMPTY_DATA); } @GetMapping("/home/admin/findStudentInCourseFile") - public List findStudentInCourseFile( - @RequestParam(value = "Folder") String Folder,@RequestParam(value = "CourseName") String CourseName){ - List files = vUserfileService.findStudentNoByWorkFolderAndCourseName(Folder,CourseName); - if (files!=null){ + public List findStudentInCourseFile( + @RequestParam(value = "Folder") String Folder, @RequestParam(value = "CourseName") String CourseName) { + List files = vUserfileService.findStudentNoByWorkFolderAndCourseName(Folder, CourseName); + if (files != null) { return files; } throw new UserException(ResultEnum.EMPTY_DATA); } @GetMapping("/home/userinfo") - public VUserinfo findUserInfo(){ - TbUser user= (TbUser)httpServletRequest.getSession().getAttribute(USER_SESSION_KEY); + public VUserinfo findUserInfo() { + TbUser user = (TbUser) httpServletRequest.getSession().getAttribute(USER_SESSION_KEY); return userService.findUserInfo(user.getColuserid()); } /** * 存储密保问题 + * * @param userque * @return */ @PostMapping("/home/adduserque") - public boolean adduserque(TbUserque userque)throws Exception{ + public boolean adduserque(TbUserque userque) throws Exception { //对密保问题加密存储 userque.setAnswer(new BigInteger(CodingUtil.encryptSHA(userque.getAnswer().getBytes())).toString(32)); return userService.addUserQue(userque); @@ -139,6 +140,7 @@ public class DataController { /** * 判断密保问题是否正确,正确返回true,错误返回false,其余反馈异常对象 + * * @param name * @param question * @param answer @@ -146,18 +148,19 @@ public class DataController { * @throws Exception */ @GetMapping("/finduserque") - public boolean findUserQue(@RequestParam(value = "name")String name - ,@RequestParam(value = "question")String question - ,@RequestParam(value = "answer")String answer)throws Exception{ + public boolean findUserQue(@RequestParam(value = "name") String name + , @RequestParam(value = "question") String question + , @RequestParam(value = "answer") String answer) throws Exception { Optional userque = userService.findUserQueByName(name); - if (!userque.isPresent()){ + if (!userque.isPresent()) { throw new UserException(ResultEnum.EMPTY_QUESTION); - }else if(question.equals(userque.get().getQuestion())){ - if(new BigInteger(CodingUtil.encryptSHA(answer.getBytes())).toString(32).equals(userque.get().getAnswer())) + } else if (question.equals(userque.get().getQuestion())) { + if (new BigInteger(CodingUtil.encryptSHA(answer.getBytes())).toString(32).equals(userque.get().getAnswer())) { return true; - else + } else { return false; - }else{ + } + } else { throw new UserException(ResultEnum.QUESTION_ERROR); } } @@ -165,53 +168,53 @@ public class DataController { @PostMapping("/resetPass") public boolean resetPass(@RequestParam(value = "name") String name , @RequestParam(value = "password") String password, - @RequestParam(value = "question") String question + @RequestParam(value = "question") String question , @RequestParam(value = "answer") String answer) throws Exception { //log.info("name:{}, password:{}, question:{}, answer:{}",name,password,question,answer); - if (findUserQue(name,question,answer)){ + if (findUserQue(name, question, answer)) { //service方法内含有对密码加密的操作 - return userService.updateColpasswordByColname(password,name); - }else { + return userService.updateColpasswordByColname(password, name); + } else { throw new UserException(ResultEnum.ILLEGAL_ACCESS); } } @GetMapping("/home/findAllNotice") - public List findAllNotice(){ + public List findAllNotice() { return noticeService.findAll(); } @PostMapping("/home/admin/addNotice") - public boolean addNotice(String content){ - TbUser user= (TbUser)httpServletRequest.getSession().getAttribute(USER_SESSION_KEY); + public boolean addNotice(String content) { + TbUser user = (TbUser) httpServletRequest.getSession().getAttribute(USER_SESSION_KEY); TbNotice notice = new TbNotice(); Date date = new Date(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String dateNowStr = sdf.format(date); Optional vAdmin = adminService.findAdminByUserId(user.getColuserid()); - if (vAdmin.isPresent()){ + if (vAdmin.isPresent()) { VAdmin admin = vAdmin.get(); notice.setAdminid(admin.getAdminid()); notice.setIssueTime(dateNowStr); notice.setNoticeContent(content); - return noticeService.addOne(notice)!=null; - }else + return noticeService.addOne(notice) != null; + } else { return false; - + } } @PostMapping("/home/admin/addoneversion") - public boolean addOneVersion(TbVersion version){ - return versionService.addOneVersion(version)!=null; + public boolean addOneVersion(TbVersion version) { + return versionService.addOneVersion(version) != null; } @PostMapping("/home/admin/addversion") - public boolean addVersion(@RequestBody List versions){ - return versionService.addAllVersion(versions)!=null; + public boolean addVersion(@RequestBody List versions) { + return versionService.addAllVersion(versions) != null; } @GetMapping("/home/findallversion") - public List findAllVersion(){ + public List findAllVersion() { return versionService.findAll(); } } diff --git a/src/main/java/com/fjy/spring/controller/DownLoadController.java b/src/main/java/com/fjy/spring/controller/DownLoadController.java index 1602549..2c68fb3 100644 --- a/src/main/java/com/fjy/spring/controller/DownLoadController.java +++ b/src/main/java/com/fjy/spring/controller/DownLoadController.java @@ -46,8 +46,9 @@ public class DownLoadController { @ResponseBody public List toDownloadAll() { List files = fileService.findAllFile();//此处做空指针判断并抛出错误 - if (files != null) + if (files != null) { return files; + } new UserException(ResultEnum.EMPTY_DATA); return null; } @@ -59,8 +60,9 @@ public class DownLoadController { //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; } @@ -103,20 +105,22 @@ public class DownLoadController { } catch (Exception e) { e.printStackTrace(); } finally { - if (bis != null) + if (bis != null) { try { bis.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } - if (bos != null) + } + if (bos != null) { try { bos.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } + } } return null; @@ -184,9 +188,15 @@ public class DownLoadController { } finally { //关闭流 try { - if (null != bufferStream) bufferStream.close(); - if (null != zipStream) zipStream.close(); - if (null != zipSource) zipSource.close(); + if (null != bufferStream) { + bufferStream.close(); + } + if (null != zipStream) { + zipStream.close(); + } + if (null != zipSource) { + zipSource.close(); + } } catch (IOException e) { e.printStackTrace(); } @@ -209,20 +219,22 @@ public class DownLoadController { } catch (Exception e) { e.printStackTrace(); } finally { - if (bis != null) + if (bis != null) { try { bis.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } - if (bos != null) + } + if (bos != null) { try { bos.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } + } } } diff --git a/src/main/java/com/fjy/spring/controller/RegisterController.java b/src/main/java/com/fjy/spring/controller/RegisterController.java index aaab1eb..33cb1c0 100644 --- a/src/main/java/com/fjy/spring/controller/RegisterController.java +++ b/src/main/java/com/fjy/spring/controller/RegisterController.java @@ -63,8 +63,9 @@ public class RegisterController { @ResponseBody public boolean doCheckStudentNo(@RequestParam(value = "studentno") String studentno){ TbStudentlist studentlist = studentService.findStudentByNo(studentno); - if (studentlist!=null) + if (studentlist!=null) { return true; + } return false; } @@ -73,8 +74,9 @@ public class RegisterController { public boolean doCheckStudent(@RequestParam(value = "studentno") String studentno, @RequestParam(value = "realname") String realname){ TbStudentlist studentlist = studentService.findByColstudentnoAndColrealname(studentno,realname); - if (studentlist!=null&&studentlist.getRegistered()!= RegisteredEnum.REGISTERED.getCode()) + if (studentlist!=null&&studentlist.getRegistered()!= RegisteredEnum.REGISTERED.getCode()) { return true; + } return false; } @@ -87,8 +89,9 @@ public class RegisterController { @ResponseBody public boolean doUserName(@RequestParam(value = "name") String name){ Optional user = userService.findByColname(name); - if (user.isPresent()) + if (user.isPresent()) { return false; + } return true; } diff --git a/src/main/java/com/fjy/spring/controller/UpLoadController.java b/src/main/java/com/fjy/spring/controller/UpLoadController.java index bc83b1b..7dac428 100644 --- a/src/main/java/com/fjy/spring/controller/UpLoadController.java +++ b/src/main/java/com/fjy/spring/controller/UpLoadController.java @@ -1,11 +1,13 @@ package com.fjy.spring.controller; import com.fjy.spring.constant.GlobalConstant; +import com.fjy.spring.domain.Homework; import com.fjy.spring.domain.TbFile; import com.fjy.spring.domain.TbLog; import com.fjy.spring.domain.TbUser; import com.fjy.spring.properties.ServerProperties; import com.fjy.spring.service.FileService; +import com.fjy.spring.service.HomeworkService; import com.fjy.spring.service.LogService; import com.fjy.spring.untils.FormatFileSizeUtil; import com.fjy.spring.untils.GetIPAddrUtil; @@ -31,11 +33,20 @@ import java.util.Map; @Slf4j public class UpLoadController { + /** + * 服务器配置信息 + */ @Autowired - private ServerProperties serverProperties;//服务器配置信息 + private ServerProperties serverProperties; + + /** + * 文件相关数据库操作 + */ + @Autowired + private FileService fileService; @Autowired - private FileService fileService;//文件相关数据库操作 + private HomeworkService homeworkService; @Autowired private LogService logService; @@ -79,20 +90,22 @@ public class UpLoadController { * 存储文件信息 */ TbFile file = new TbFile(); - file.setColfilesize(new FormatFileSizeUtil().GetFileSize(imageFile.getSize())); + file.setColfilesize(FormatFileSizeUtil.GetFileSize(imageFile.getSize())); file.setColfilename(filename); file.setColfilepath(uploadUrl + filename); file.setColip(request.getRemoteAddr()); file.setColuserid(user.getColuserid()); - if (fileService.addFile(file)) + if (fileService.addFile(file)) { log.info("记录写入数据库成功"); - //System.out.println("记录写入数据库成功"); - else + } + //System.out.println("记录写入数据库成功"); + else { log.error("记录写入数据库失败"); + } //System.out.println("记录写入数据库失败"); log.info("文件上传到: " + uploadUrl + filename); - log.info("文件大小: " + new FormatFileSizeUtil().GetFileSize(imageFile.getSize())); + log.info("文件大小: " + FormatFileSizeUtil.GetFileSize(imageFile.getSize())); log.info("文件名: " + filename); File targetFile = new File(uploadUrl + filename); @@ -130,6 +143,7 @@ public class UpLoadController { public void moreUpload(HttpServletRequest request, @RequestParam(value = "courseName", required = false) String courseName, @RequestParam(value = "folder", required = false) String folder, + @RequestParam(value = "workid") Integer workId, @RequestParam(value = "rename", required = true) boolean rename) { MultipartHttpServletRequest multipartHttpServletRequest = (MultipartHttpServletRequest) request; @@ -158,13 +172,21 @@ public class UpLoadController { List fileList = new ArrayList(); for (MultipartFile file : files.values()) { + Homework homework = homeworkService.findById(workId); + String filePrefix = homework.getFilePrefix(); + String fileSuffix = homework.getFileSuffix(); String filename = file.getOriginalFilename(); - String suffix = "." + filename.substring(filename.lastIndexOf(".") + 1);//获取文件后缀 + + //获取文件后缀 + String suffix = "." + filename.substring(filename.lastIndexOf(".") + 1); TbFile tbFile = new TbFile(); String pathname; + + + //文件重命名 if (rename) { - pathname = uploadUrl + user.getColstudentno() + user.getColrealname() + suffix; - tbFile.setColfilename(user.getColstudentno() + user.getColrealname() + suffix); + pathname = uploadUrl + filePrefix + user.getColstudentno() + user.getColrealname() + fileSuffix + suffix; + tbFile.setColfilename(filePrefix + user.getColstudentno() + user.getColrealname() + fileSuffix + suffix); } else { pathname = uploadUrl + filename; tbFile.setColfilename(filename); @@ -172,39 +194,41 @@ public class UpLoadController { File targetFile = new File(pathname); //若文件已存在则自动重命名 - if (targetFile.exists()){ + if (targetFile.exists()) { String bakpathname; if (rename) { - bakpathname = uploadUrl + "bak/" +user.getColstudentno() + user.getColrealname() + suffix; + bakpathname = uploadUrl + "bak/" + user.getColstudentno() + user.getColrealname() + suffix; } else { - bakpathname = uploadUrl +"bak/"+ filename; + bakpathname = uploadUrl + "bak/" + filename; } - log.info("源文件路径:"+pathname); + log.info("源文件路径:" + pathname); TbFile file1 = fileService.findByFilepath(pathname); - file1.setColfilepath(bakpathname+"."+dateNowStr2+".bak"); - file1.setColfilename(file1.getColfilename()+"."+dateNowStr2+".bak"); - if (fileService.addFile(file1)) + file1.setColfilepath(bakpathname + "." + dateNowStr2 + ".bak"); + file1.setColfilename(file1.getColfilename() + "." + dateNowStr2 + ".bak"); + if (fileService.addFile(file1)) { log.info("重命名文件数据库更新成功"); - else + } else { log.error("重命名文件数据库更新失败"); - File mvfile = new File(bakpathname+"."+dateNowStr2+".bak"); + } + File mvfile = new File(bakpathname + "." + dateNowStr2 + ".bak"); try { FileUtils.moveFile(targetFile, mvfile); - log.info("源文件:"+targetFile.getName()+"已重命名为:"+ mvfile.getName()); + log.info("源文件:" + targetFile.getName() + "已重命名为:" + mvfile.getName()); } catch (IOException e) { e.printStackTrace(); } } log.info("文件上传到: " + uploadUrl + filename); - log.info("文件大小: " + new FormatFileSizeUtil().GetFileSize(file.getSize())); + log.info("文件大小: " + FormatFileSizeUtil.GetFileSize(file.getSize())); log.info("文件名: " + filename); - tbFile.setColfilesize(new FormatFileSizeUtil().GetFileSize(file.getSize())); + tbFile.setColfilesize(FormatFileSizeUtil.GetFileSize(file.getSize())); tbFile.setColtime(dateNowStr); tbFile.setColrealname(filename); - tbFile.setColfilepath(pathname);//文件自动学号+姓名命名 + //文件自动学号+姓名命名 + tbFile.setColfilepath(pathname); tbFile.setColip(request.getRemoteAddr()); tbFile.setColuserid(user.getColuserid()); tbFile.setCourseName(courseName); @@ -217,10 +241,11 @@ public class UpLoadController { logs.setColheader(user.getColname() + "上传了'" + filename + "'文件"); logService.addLogRec(logs); - if (fileService.addFile(tbFile)) + if (fileService.addFile(tbFile)) { log.info("记录写入数据库成功"); - else + } else { log.error("记录写入数据库失败"); + } if (!targetFile.exists()) { try { diff --git a/src/main/java/com/fjy/spring/domain/Homework.java b/src/main/java/com/fjy/spring/domain/Homework.java index 74aa8bc..1b17d61 100644 --- a/src/main/java/com/fjy/spring/domain/Homework.java +++ b/src/main/java/com/fjy/spring/domain/Homework.java @@ -30,4 +30,10 @@ public class Homework { @Column(name = "workremark") private String Remark; + + @Column(name = "pre") + private String filePrefix; + + @Column(name = "suf") + private String fileSuffix; } diff --git a/src/main/java/com/fjy/spring/interceptor/AdminInterceptor.java b/src/main/java/com/fjy/spring/interceptor/AdminInterceptor.java index 17ffbda..ac5b24b 100644 --- a/src/main/java/com/fjy/spring/interceptor/AdminInterceptor.java +++ b/src/main/java/com/fjy/spring/interceptor/AdminInterceptor.java @@ -24,7 +24,8 @@ public class AdminInterceptor implements HandlerInterceptor { public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { TbUser user = (TbUser)request.getSession().getAttribute(GlobalConstant.USER_SESSION_KEY); //log.info(user.getColuserid()+""); - if (adminService == null) {//解决service为null无法注入问题 + //解决service为null无法注入问题 + if (adminService == null) { BeanFactory factory = WebApplicationContextUtils.getRequiredWebApplicationContext(request.getServletContext()); adminService = (AdminService) factory.getBean("adminService"); } @@ -33,8 +34,9 @@ public class AdminInterceptor implements HandlerInterceptor { if (!admin.isPresent()){ response.sendRedirect("/cms/home"); return false; - }else + }else { return true; + } } } diff --git a/src/main/java/com/fjy/spring/service/FileService.java b/src/main/java/com/fjy/spring/service/FileService.java index fa7e489..fe30f59 100644 --- a/src/main/java/com/fjy/spring/service/FileService.java +++ b/src/main/java/com/fjy/spring/service/FileService.java @@ -15,15 +15,17 @@ public class FileService { public boolean addFile(TbFile tbFile) { TbFile file = tbFileRepository.save(tbFile); - if (file != null) + if (file != null) { return true; + } return false; } public List findFile(TbFile tbFile){ List files = tbFileRepository.findByColfilename(tbFile.getColfilename()); - if (files!=null) + if (files!=null) { return files; + } return null; } diff --git a/src/main/java/com/fjy/spring/service/HomeworkService.java b/src/main/java/com/fjy/spring/service/HomeworkService.java index 5ac3f42..af4a678 100644 --- a/src/main/java/com/fjy/spring/service/HomeworkService.java +++ b/src/main/java/com/fjy/spring/service/HomeworkService.java @@ -2,13 +2,13 @@ package com.fjy.spring.service; import com.fjy.spring.domain.Homework; import com.fjy.spring.domain.VHomework; -import com.fjy.spring.domain.VWorkDetail; import com.fjy.spring.repository.HomeworkRepository; import com.fjy.spring.repository.VHomeworkRepository; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.List; +import java.util.Optional; @Service public class HomeworkService { @@ -25,4 +25,12 @@ public class HomeworkService { public List findAllVHomework(){ return vHomeworkRepository.findAll(); } + + public Homework findById(Integer id){ + Optional homework = homeworkRepository.findById(id); + if (homework.isPresent()){ + return (Homework)homework.get(); + } + return null; + } } diff --git a/src/main/java/com/fjy/spring/service/UserService.java b/src/main/java/com/fjy/spring/service/UserService.java index 7114ab8..b4960b2 100644 --- a/src/main/java/com/fjy/spring/service/UserService.java +++ b/src/main/java/com/fjy/spring/service/UserService.java @@ -81,8 +81,9 @@ public class UserService { public boolean addUserQue(TbUserque userque) { TbUserque tbUserque = userqueRepository.save(userque); - if (tbUserque != null) + if (tbUserque != null) { return true; + } return false; } diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 7ef289a..9efaa1c 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -1,4 +1,4 @@ #控制配置文件调用 spring: profiles: - active: prod \ No newline at end of file + active: dev \ No newline at end of file diff --git a/src/main/resources/logback-spring.xml b/src/main/resources/logback-spring.xml index 83a471d..02d1ae7 100644 --- a/src/main/resources/logback-spring.xml +++ b/src/main/resources/logback-spring.xml @@ -25,8 +25,8 @@ - - /www/cmsfile/%d/info.%d.log + F:\JAVA Workspace\Temp\log\%d\info.%d.log + @@ -44,8 +44,8 @@ - - /www/cmsfile/%d/error.%d.log + F:\JAVA Workspace\Temp\log\error.%d.log + diff --git a/src/main/resources/static/js/homepage.js b/src/main/resources/static/js/homepage.js index 1e171b4..d1ef130 100644 --- a/src/main/resources/static/js/homepage.js +++ b/src/main/resources/static/js/homepage.js @@ -3,6 +3,7 @@ var month = dt.getMonth() + 1; var day = dt.getDate(); var year = dt.getFullYear(); var cur = year + '-' + month + '-' + day; + function DateDiff(sDate1, sDate2) { //sDate1和sDate2是2002-12-18格式 var aDate, oDate1, oDate2, iDays aDate = sDate1.split("-") @@ -12,9 +13,11 @@ function DateDiff(sDate1, sDate2) { //sDate1和sDate2是2002-12-18格式 iDays = parseInt(Math.abs(oDate1 - oDate2) / 1000 / 60 / 60 / 24) //把相差的毫秒数转换为天数 return iDays } -function displayStyle(id,type) { - document.getElementById(id).style.display=type; + +function displayStyle(id, type) { + document.getElementById(id).style.display = type; } + var Main = { data() { var checkName = (rule, value, callback) => { @@ -66,7 +69,7 @@ var Main = { colrealname: '', colemail: '' }, - iShow:true, + iShow: true, rules2: { colpassword: [ {required: true, validator: validatePass, trigger: 'blur'} @@ -95,7 +98,7 @@ var Main = { activeName: 'login', fileList: [], DownloadList: [], - NoticeList:[ + NoticeList: [ { noticeid: 1, adminid: 1, @@ -109,12 +112,12 @@ var Main = { issueTime: "2018-2-26 11:13" } ], - VersionList:[ + VersionList: [ { - date:'2018-01-30', - content:'实现数据库查询用户,获取密码,编写了单元测试类', - version:'V0.1', - user:'F嘉阳' + date: '2018-01-30', + content: '实现数据库查询用户,获取密码,编写了单元测试类', + version: 'V0.1', + user: 'F嘉阳' } ], tableHomeworkData: [ @@ -170,7 +173,7 @@ var Main = { that.getFileList(); },1000);*/ this.getFileList(); - axios.get(getRootPath_web()+'/home/findAllHomework') + axios.get(getRootPath_web() + '/home/findAllHomework') .then(function (response) { console.log(response.data); that.tableHomeworkData = response.data; @@ -179,7 +182,7 @@ var Main = { .catch(function (error) { console.log(error); }); - axios.get(getRootPath_web()+'/home/findAllNotice') + axios.get(getRootPath_web() + '/home/findAllNotice') .then(function (response) { console.log(response.data); that.NoticeList = response.data; @@ -188,7 +191,7 @@ var Main = { .catch(function (error) { console.log(error); }); - axios.get(getRootPath_web()+'/home/findallversion') + axios.get(getRootPath_web() + '/home/findallversion') .then(function (response) { console.log(response.data); that.VersionList = response.data; @@ -200,9 +203,9 @@ var Main = { }) }, methods: { - getFileList(){ + getFileList() { let that = this; - axios.get(getRootPath_web()+'/home/download/findone') + axios.get(getRootPath_web() + '/home/download/findone') .then(function (response) { //console.log(response.data); that.DownloadList = response.data; @@ -232,7 +235,7 @@ var Main = { }); }, uploadURL(row) { - return getRootPath_web()+"/home/moreUpload?courseName=" + row.coursename + "&folder=" + row.workfolder+"&rename=true"; + return getRootPath_web() + "/home/moreUpload?courseName=" + row.coursename + "&folder=" + row.workfolder + "&workid=" + row.workid + "&rename=true"; }, limitTime(row) { @@ -243,7 +246,7 @@ var Main = { let that = this; if (valid) { axios({ - url: getRootPath_web()+'/' + url, + url: getRootPath_web() + '/' + url, method: 'post', data: { content: this.$refs.content.value @@ -261,13 +264,13 @@ var Main = { } }).then(function (response) { console.log(response.data); - if (response.data===true){ + if (response.data === true) { //that.$refs[formName].submit; //return true; that.openNotiSuccess("成功", "反馈成功!") - }else if (response.data===false){ + } else if (response.data === false) { that.openNotiError("失败", "反馈失败!"); - }else { + } else { that.openNotiError("错误", response.data.message); } }).catch(function (error) { @@ -293,22 +296,24 @@ var Main = { let that = this; this.$refs.upload.submit(); this.openNotiSuccess("成功", "文件上传成功!"); - setTimeout(function () {that.getFileList();},1000); + setTimeout(function () { + that.getFileList(); + }, 1000); }, handleRemove(file, fileList) { console.log(file, fileList); }, ClickToJump(targe) { - window.location.href = getRootPath_web()+"/" + targe; + window.location.href = getRootPath_web() + "/" + targe; }, handleDownload(row) { /*var url = window.location.protocol+"://"+window.location.host+":"+window.location.port+"/"*/ - window.open(getRootPath_web()+"/home/download/dodownload?fileId=" + row.colfileid); + window.open(getRootPath_web() + "/home/download/dodownload?fileId=" + row.colfileid); }, handleDelete(row) { let that = this; axios({ - url: getRootPath_web()+'/home/filedelete', + url: getRootPath_web() + '/home/filedelete', method: 'post', data: { fileid: row.colfileid @@ -326,14 +331,14 @@ var Main = { } }).then(function (response) { console.log(response.data); - if (response.data===true){ + if (response.data === true) { //that.$refs[formName].submit; //return true; that.openNotiSuccess("成功", "删除成功!"); that.getFileList(); - }else if (response.data===false){ + } else if (response.data === false) { that.openNotiError("失败", "删除失败!"); - }else { + } else { that.openNotiError("错误", response.data.message); } }).catch(function (error) { @@ -341,17 +346,17 @@ var Main = { that.openNotiError("错误", "服务器错误!"); }); }, - isShow(row){ + isShow(row) { let that = this; - console.log(row.worktime+"||"+row.workid); - if (compareTime(cur,row.worktime)){ + console.log(row.worktime + "||" + row.workid); + if (compareTime(cur, row.worktime)) { console.log("true"); return true; //提交时间合法 //document.getElementById("btn-group").style.display=""; //displayStyle("btn-show"+row.workid,"none"); //displayStyle("btn-group"+row.workid,""); - }else { + } else { console.log("false"); return false; //提交时间不合法 @@ -363,25 +368,25 @@ var Main = { }, handlePreview(row) { console.log(row); - /* let that = this; - console.log(row.worktime+"||"+row.workid); - if (compareTime(cur,row.worktime)){ - that.isShow = true; - console.log("Show"+that.isShow); - //提交时间合法 - //document.getElementById("btn-group").style.display=""; - //displayStyle("btn-show"+row.workid,"none"); - //displayStyle("btn-group"+row.workid,""); - } - if (!compareTime(cur,row.worktime)){ - that.isShow = false; - console.log("EShow"+that.isShow); - //提交时间不合法 - //displayStyle("btn-show"+row.workid,""); - //displayStyle("btn-group"+row.workid,"none"); - //displayStyle("btn-show"); - //document.getElementById("btn-show").style.display=""; - }*/ + /* let that = this; + console.log(row.worktime+"||"+row.workid); + if (compareTime(cur,row.worktime)){ + that.isShow = true; + console.log("Show"+that.isShow); + //提交时间合法 + //document.getElementById("btn-group").style.display=""; + //displayStyle("btn-show"+row.workid,"none"); + //displayStyle("btn-group"+row.workid,""); + } + if (!compareTime(cur,row.worktime)){ + that.isShow = false; + console.log("EShow"+that.isShow); + //提交时间不合法 + //displayStyle("btn-show"+row.workid,""); + //displayStyle("btn-group"+row.workid,"none"); + //displayStyle("btn-show"); + //document.getElementById("btn-show").style.display=""; + }*/ }, handleExceed(files, fileList) { this.$message.warning(`当前限制选择 3 个文件,本次选择了 ${files.length} 个文件,共选择了 ${files.length + fileList.length} 个文件`); diff --git a/src/test/java/com/fjy/spring/LoggerTest.java b/src/test/java/com/fjy/spring/LoggerTest.java index d52cf31..8fd76df 100644 --- a/src/test/java/com/fjy/spring/LoggerTest.java +++ b/src/test/java/com/fjy/spring/LoggerTest.java @@ -6,7 +6,7 @@ import org.junit.runner.RunWith; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit4.SpringRunner; -/* + @RunWith(SpringRunner.class) @SpringBootTest @Slf4j @@ -22,4 +22,4 @@ public class LoggerTest { log.error("error..."); } } -*/ + diff --git a/src/test/java/com/fjy/spring/controller/DataControllerTest.java b/src/test/java/com/fjy/spring/controller/DataControllerTest.java index a0e4531..c13cd56 100644 --- a/src/test/java/com/fjy/spring/controller/DataControllerTest.java +++ b/src/test/java/com/fjy/spring/controller/DataControllerTest.java @@ -12,7 +12,7 @@ import org.springframework.test.web.servlet.result.MockMvcResultMatchers; import javax.transaction.Transactional; -/* + @RunWith(SpringRunner.class) @SpringBootTest @AutoConfigureMockMvc @@ -21,42 +21,42 @@ public class DataControllerTest { @Autowired private MockMvc mvc; - */ -/** + + /** * 使用此单元测试前要注销拦截器,否则测试不通过 * @throws Exception - *//* + */ @Test @Transactional - public void adduserque() throws Exception{ + public void adduserque() throws Exception { mvc.perform(MockMvcRequestBuilders.post("/home/adduserque") - .param("coluserid","53") - .param("question","您母亲的姓名是?") - .param("answer","YHM")) + .param("coluserid", "53") + .param("question", "您母亲的姓名是?") + .param("answer", "YHM")) .andExpect(MockMvcResultMatchers.content().string("true")); } - */ -/** - *测试找回密码 + + /** + * 测试找回密码 * @throws Exception - *//* + */ @Test - public void findUserQue() throws Exception{ + public void findUserQue() throws Exception { //测试问题和答案均正确 mvc.perform(MockMvcRequestBuilders.get("/finduserque") - .param("name","root") - .param("question","您配偶的姓名是?") - .param("answer","abc")) + .param("name", "root") + .param("question", "您配偶的姓名是?") + .param("answer", "abc")) .andExpect(MockMvcResultMatchers.content().string("true")); //测试问题错误 mvc.perform(MockMvcRequestBuilders.get("/finduserque") - .param("name","root") - .param("question","您配偶的姓名是") - .param("answer","abc")) + .param("name", "root") + .param("question", "您配偶的姓名是") + .param("answer", "abc")) .andExpect(MockMvcResultMatchers.content().json("{\n" + " \"code\": 611,\n" + " \"message\": \"问题与答案不匹配\",\n" + @@ -65,16 +65,16 @@ public class DataControllerTest { //测试问题正确,答案错误 mvc.perform(MockMvcRequestBuilders.get("/finduserque") - .param("name","root") - .param("question","您配偶的姓名是?") - .param("answer","a")) + .param("name", "root") + .param("question", "您配偶的姓名是?") + .param("answer", "a")) .andExpect(MockMvcResultMatchers.content().string("false")); //未设置问题 mvc.perform(MockMvcRequestBuilders.get("/finduserque") - .param("name","roo") - .param("question","您配偶的姓名是?") - .param("answer","a")) + .param("name", "roo") + .param("question", "您配偶的姓名是?") + .param("answer", "a")) .andExpect(MockMvcResultMatchers.content().json("{\n" + " \"code\": 610,\n" + " \"message\": \"该用户未设置密保问题\",\n" + @@ -82,20 +82,20 @@ public class DataControllerTest { "}")); } - */ -/** - * 测试忘记密码操作 + + + /* * 测试忘记密码操作 * @throws Exception - *//* + */ @Test @Transactional - public void resetPass() throws Exception{ + public void resetPass() throws Exception { mvc.perform(MockMvcRequestBuilders.post("/resetPass") - .param("name","root") - .param("question","您配偶的姓名是?") - .param("answer","abc") - .param("password","admin")) + .param("name", "root") + .param("question", "您配偶的姓名是?") + .param("answer", "abc") + .param("password", "admin")) .andExpect(MockMvcResultMatchers.content().string("true")); } -}*/ +} diff --git a/src/test/java/com/fjy/spring/controller/LoginControllerTest.java b/src/test/java/com/fjy/spring/controller/LoginControllerTest.java index 6524c66..89e62e3 100644 --- a/src/test/java/com/fjy/spring/controller/LoginControllerTest.java +++ b/src/test/java/com/fjy/spring/controller/LoginControllerTest.java @@ -12,7 +12,7 @@ import org.springframework.test.web.servlet.result.MockMvcResultMatchers; import static org.junit.Assert.*; -/* + @RunWith(SpringRunner.class) @SpringBootTest @AutoConfigureMockMvc @@ -40,4 +40,4 @@ public class LoginControllerTest { " \"data\": null\n" + "}")); } -}*/ +} diff --git a/src/test/java/com/fjy/spring/controller/RegisterControllerTest.java b/src/test/java/com/fjy/spring/controller/RegisterControllerTest.java index 617b4f4..88f0e8b 100644 --- a/src/test/java/com/fjy/spring/controller/RegisterControllerTest.java +++ b/src/test/java/com/fjy/spring/controller/RegisterControllerTest.java @@ -12,7 +12,7 @@ import org.springframework.test.web.servlet.result.MockMvcResultMatchers; import static org.junit.Assert.*; -/* + @RunWith(SpringRunner.class) @SpringBootTest @AutoConfigureMockMvc @@ -74,4 +74,4 @@ public class RegisterControllerTest { .param("name","root1")) .andExpect(MockMvcResultMatchers.content().string("true")); } -}*/ +} diff --git a/src/test/java/com/fjy/spring/controller/TestControllerTest.java b/src/test/java/com/fjy/spring/controller/TestControllerTest.java index a9639ef..cd7ddb9 100644 --- a/src/test/java/com/fjy/spring/controller/TestControllerTest.java +++ b/src/test/java/com/fjy/spring/controller/TestControllerTest.java @@ -11,7 +11,7 @@ import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; import org.springframework.test.web.servlet.result.MockMvcResultMatchers; import static org.junit.Assert.*; -/* + @RunWith(SpringRunner.class) @SpringBootTest @AutoConfigureMockMvc @@ -39,4 +39,4 @@ public class TestControllerTest { mvc.perform(MockMvcRequestBuilders.get("/test/id/1")) .andExpect(MockMvcResultMatchers.status().isOk()); } -}*/ +}