——————————DescriptionStart——————————
运行环境
Java≥8、MySQL≥5.7
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明





基于javaweb的SpringBoot在线网盘系统(java+jsp+springboot+maven+mysql+thymeleaf+ftp)
一、项目简述
功能:用户的邮箱注册、验证码验证以及用户登录。 不需要注册账号,也可以上传满足条件的临时文件,但是只4小时内有效。 文件的管理,上传、下载、重命名、删除、查看统计数据、分类管理等。 文件夹的管理,创建、删除、重命名。 文件的分享,支持通过链接和二维码的分享方式等等,以及管理员对用户的管理等等。
二、项目运行
环境配置:
Jdk1.8 + mysql + Eclispe(IntelliJ IDEA,Eclispe,MyEclispe,Sts都支持)
项目技术:
JSP +Springboot+ SpringMVC + MyBatis + ThymeLeaf + FTP+ JavaScript + JQuery + Ajax + maven等等
——————————CodeStart——————————
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
| @Controller public class LoginController extends BaseController {
private Logger logger = LogUtils.getInstance(LoginController.class);
@GetMapping("/admin") public String adminLogin(){ User user = userService.getUserByOpenId("123456"); logger.info("使用免登陆方式登录成功!"+user); session.setAttribute("loginUser", user); return "redirect:/index"; }
@PostMapping("/register") public String register(User user, String code, Map<String, Object> map) { String uCode = (String) session.getAttribute(user.getEmail() + "_code"); if (!code.equals(uCode)) { map.put("errorMsg", "验证码错误"); return "index"; } user.setUserName(user.getUserName().trim()); user.setImagePath("https://p.qpic.cn/qqconnect/0/app_101851241_1582451550/100?max-age=2592000&t=0"); user.setRegisterTime(new Date()); user.setRole(1); if (userService.insert(user)) { FileStore store = FileStore.builder().userId(user.getUserId()).currentSize(0).build();
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
| * @Param [map] * @return java.lang.String **/ @GetMapping("/video-files") public String toVideoFilePage( Map<String, Object> map) { List<MyFile> files = myFileService.getFilesByType(loginUser.getFileStoreId(),3); FileStoreStatistics statistics = myFileService.getCountStatistics(loginUser.getFileStoreId()); map.put("statistics", statistics); map.put("files", files); map.put("permission", fileStoreService.getFileStoreByUserId(loginUser.getUserId()).getPermission()); return "u-admin/video-files"; }
@GetMapping("/music-files") public String toMusicFilePage( Map<String, Object> map) { List<MyFile> files = myFileService.getFilesByType(loginUser.getFileStoreId(),4); FileStoreStatistics statistics = myFileService.getCountStatistics(loginUser.getFileStoreId()); map.put("statistics", statistics); map.put("files", files); map.put("permission", fileStoreService.getFileStoreByUserId(loginUser.getUserId()).getPermission()); return "u-admin/music-files"; }
@GetMapping("/other-files") public String toOtherFilePage( Map<String, Object> map) {
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
| * @Param [fId, fName, error, map] **/ @GetMapping("/files") public String toFileStorePage(Integer fId, String fName, Integer error, Map<String, Object> map) { if (error != null) { if (error == 1) { map.put("error", "添加失败!当前已存在同名文件夹"); } if (error == 2) { map.put("error", "重命名失败!文件夹已存在"); } } List<FileFolder> folders = null; List<MyFile> files = null; FileFolder nowFolder = null; List<FileFolder> location = new ArrayList<>(); if (fId == null || fId <= 0) { fId = 0; folders = fileFolderService.getRootFoldersByFileStoreId(loginUser.getFileStoreId()); files = myFileService.getRootFilesByFileStoreId(loginUser.getFileStoreId()); nowFolder = FileFolder.builder().fileFolderId(fId).build(); location.add(nowFolder); } else { FileFolder folder = fileFolderService.getFileFolderByFileFolderId(fId); if (folder.getFileStoreId() - loginUser.getFileStoreId() != 0){ return "redirect:/error401Page"; } folders = fileFolderService.getFileFolderByParentFolderId(fId); files = myFileService.getFilesByParentFolderId(fId); nowFolder = fileFolderService.getFileFolderByFileFolderId(fId); FileFolder temp = nowFolder;
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
| boolean b = FtpUtil.reNameFile(myFile.getMyFilePath() + "/" + oldName+myFile.getPostfix(), myFile.getMyFilePath() + "/" + newName+myFile.getPostfix()); if (b){ Integer integer = myFileService.updateFile( MyFile.builder().myFileId(myFile.getMyFileId()).myFileName(newName).build()); if (integer == 1){ logger.info("修改文件名成功!原文件名:"+oldName+" 新文件名:"+newName); }else{ logger.error("修改文件名失败!原文件名:"+oldName+" 新文件名:"+newName); } } } } return "redirect:/files?fId="+myFile.getParentFolderId(); }
@GetMapping("getQrCode") @ResponseBody public Map<String,Object> getQrCode(@RequestParam Integer id,@RequestParam String url){ Map<String,Object> map = new HashMap<>(); map.put("imgPath","https://ss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=2654852821,3851565636&fm=26&gp=0.jpg"); if (id != null){ MyFile file = myFileService.getFileByFileId(id); if (file != null){ try { String path = request.getSession().getServletContext().getRealPath("/user_img/"); url = url+"/file/share?t="+ UUID.randomUUID().toString().substring(0,10) +"&f="+file.getMyFileId()+"&p="+file.getUploadTime().getTime()+""+file.getSize()+"&flag=1"; File targetFile = new File(path, ""); if (!targetFile.exists()) { targetFile.mkdirs(); } File f = new File(path, id + ".jpg"); if (!f.exists()){ OutputStream os = new FileOutputStream(f);
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
| * @Param [map] * @return java.lang.String **/ @GetMapping("/index") public String index(Map<String, Object> map) { FileStoreStatistics statistics = myFileService.getCountStatistics(loginUser.getFileStoreId()); statistics.setFileStore(fileStoreService.getFileStoreById(loginUser.getFileStoreId())); map.put("statistics", statistics); return "u-admin/index"; }
@GetMapping("/help") public String helpPage(Map<String, Object> map) { FileStoreStatistics statistics = myFileService.getCountStatistics(loginUser.getFileStoreId()); map.put("statistics", statistics); return "u-admin/help"; } } package com.moti.controller;
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
| * @return java.lang.String **/ @GetMapping("/manages-users") public String manageUsers(Map<String,Object> map,Integer cur){ if (loginUser.getRole() == 1){ logger.error("当前登录用户:"+loginUser.getUserName()+"无管理员权限!"); return "redirect:/error401Page"; } Integer usersCount = userService.getUsersCount(); cur = (cur == null || cur<0)?0:cur; FileStoreStatistics statistics = myFileService.getCountStatistics(loginUser.getFileStoreId()); Page<Object> page = PageHelper.startPage(cur, 20); List<UserToShow> users = userService.getUsers(); map.put("statistics", statistics); map.put("users", users); map.put("page", page); map.put("usersCount", usersCount); logger.info("用户管理域的内容:"+map); return "admin/manage-users"; }
@GetMapping("/updateStoreInfo") @ResponseBody public String updateStoreInfo(Integer uId,Integer pre,Integer size){ Integer integer = fileStoreService.updatePermission(uId, pre, size*1024); if (integer == 1) { logger.info("修改用户"+userService.queryById(uId).getUserName()+":的权限和仓库大小成功!"); return "200"; }else { logger.error("修改用户"+userService.queryById(uId).getUserName()+":的权限和仓库大小失败!"); return "500"; } }
|
——————————PayStart——————————
项目链接:
https://javayms.github.io?id=051422282105200cg
https://javayms.pages.dev?id=051422282105200cg