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






基于javaweb的SpringBoot图书管理系统(java+springboot+jsp+bootstrap+maven+mysql)
项目介绍
本系统分为管理员与普通用户两种角色; 管理员角色包含以下功能: 借书管理,图书信息管理,图书分类管理,用户管理,角色管理,还书管理,登录页面等功能。
用户角色包含以下功能:借阅管理,图书检索,查看借还记录,查看图书详情,还书管理,登录页面等功能。
环境需要
1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。
2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA;
3.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS;
4.数据库:MySql 5.7版本;
5.是否Maven项目:是;
技术栈
后端:SpringBoot
前端:JSP+CSS+JavaScript+bootstrap
使用说明
运行项目,在浏览器中输入localhost:8083/ 登录
——————————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 38 39
|
@RequestMapping(value = "/uploadFile", method = RequestMethod.POST) @ResponseBody public Map<String, Object> uploadFile(MultipartFile file) throws Exception { Map<String, Object> map = new HashMap<>(); if (!file.isEmpty()) { String fileName = file.getOriginalFilename(); String suffixName = fileName.substring(fileName.lastIndexOf(".")); String newFileName = UUID.randomUUID() + suffixName;
Date date = new Date(); int hashcode = fileName.hashCode(); int dir1 = hashcode & 0xf; int dir2 = (hashcode & 0xf0) >> 4; String path = uploadFilePath + new SimpleDateFormat("yyyy/MM/dd").format(date) + "/" + dir1 + "/" + dir2 + "/"; FileUtils.copyInputStreamToFile(file.getInputStream(), new File(path + newFileName)); map.put("code", 0); map.put("msg", "上传成功"); System.out.println("http://localhost:8080/uploads/" + new SimpleDateFormat("yyyy/MM/dd").format(date) + "/" + dir1 + "/" + dir2 + "/" + newFileName); } return map; }
@RequestMapping(value = "/ckeditorUpload", method = RequestMethod.POST) @ResponseBody public String ckeditorUpload(@RequestParam("upload") MultipartFile file, String CKEditorFuncNum) throws IOException {
|
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
| bookInfoDataGridDataSource.setRows(bookInfoList); return bookInfoDataGridDataSource; }
@GetMapping("/detail") @LoginRequired public JsonData bookInfoDetail(Integer bookId) { List<BookInfo> bookInfos = bookInfoService.selectBookById(bookId); for (BookInfo bookInfo : bookInfos) { List<BookType> bookTypeList = bookTypeService.selectBookTypeListByBookTypeId(bookInfo.getBookType()); for (BookType bookType : bookTypeList) { bookInfo.setTypes(bookType.getBookTypeName()); } } return JsonData.success(bookInfos); }
@PostMapping("/info") @LoginRequired public JsonData bookInfo(Integer bookId) { return JsonData.success(bookInfoService.selectBookInfoById(bookId)); } } package io.hailiang.web.book.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
| * @description: 根据id删除用户 */ @DeleteMapping("/delete") @LoginRequired public JsonData deleteUser(@RequestParam(value = "userId") Long userId) { roleService.deleteRoleUserRsByUserId(userId); int count = userService.deleteUser(userId); if (count > 0) { return JsonData.success(count, "删除成功"); } else { return JsonData.fail("删除失败"); } }
@PostMapping("/sendMail") @LoginRequired public JsonData sendMail(@RequestParam(value = "toMail") String toMail, @RequestParam(value = "userId") Long userId) { if (StringUtils.isEmpty(toMail)) { return JsonData.fail("用户邮箱不能为空"); } String defaultPassword = PasswordCreateUtil.createPassWord(8); User user = new User(); user.setUserId(userId); user.setUserPassword(defaultPassword); int count = userService.updateUser(user); if (count > 0) { mailService.sendSimpleMail(toMail, "重置密码", "您的初始密码为:" + defaultPassword); return JsonData.success(count, "重置密码成功"); } else { return JsonData.fail("重置密码失败"); } }
|
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
| StringBuffer stringBuffer = new StringBuffer(); for (Role role : roleList) { stringBuffer.append("," + role.getRoleName()); } user.setRoles(stringBuffer.toString().replaceFirst(",", "")); session.setAttribute("user", user); List<Permission> permissions = permissionService.queryPermissionsByUser(user); Map<Integer, Permission> permissionMap = new HashMap<>(); Permission root = null; Set<String> uriSet = new HashSet<>(); for (Permission permission : permissions) { permissionMap.put(permission.getPermissionId(), permission); if (permission.getPermissionUrl() != null && !"".equals(permission.getPermissionUrl())) { uriSet.add(permission.getPermissionUrl()); } } session.setAttribute("authUriSet", uriSet); for (Permission permission : permissions) { Permission child = permission; if (child.getPermissionParentId() == null) { root = permission; } else { Permission parent = permissionMap.get(child.getPermissionParentId()); parent.getChildren().add(child); } } session.setAttribute("rootPermission", root); return JsonData.success(); } else { return JsonData.fail("用户名或密码错误!"); } }
@PostMapping("/save") @LoginRequired public JsonData saveUser(User user) { int count = userService.saveUser(user); if (count > 0) { return JsonData.success(count, "添加成功"); } else {
|
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
| public JsonData updateUser(User user) { int count = userService.updateUser(user); if (count > 0) { return JsonData.success(count, "更新成功"); } else { return JsonData.fail("更新失败"); }
}
@DeleteMapping("/delete") @LoginRequired public JsonData deleteUser(@RequestParam(value = "userId") Long userId) { roleService.deleteRoleUserRsByUserId(userId); int count = userService.deleteUser(userId); if (count > 0) { return JsonData.success(count, "删除成功"); } else { return JsonData.fail("删除失败"); } }
@PostMapping("/sendMail") @LoginRequired public JsonData sendMail(@RequestParam(value = "toMail") String toMail, @RequestParam(value = "userId") Long userId) {
|
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 50 51 52
| BookInfo bookInfo = new BookInfo(); bookInfo.setBookId(lendReturnList.getBookId()); bookInfo.setBookState(1); bookInfoService.updateBookInfo(bookInfo); if (i > 0) { return JsonData.success(i, "借阅成功"); } else { return JsonData.fail("借阅失败"); }
}
@PostMapping("/lendreturnrecord") @LoginRequired public DataGridDataSource<LendReturnList> selectLendReturnRecordByUserId(@RequestParam(value = "page", required = false, defaultValue = "1") Integer page, @RequestParam(value = "rows", required = false, defaultValue = "5") Integer rows, HttpSession session) throws ParseException {
User currentUser = (User) session.getAttribute("user"); PageBean pageBean = new PageBean(page, rows); Map<String, Object> map = new HashMap<>(); map.put("userId", currentUser.getUserId()); map.put("start", pageBean.getStart()); map.put("size", pageBean.getPageSize()); List<LendReturnList> lendReturnLists = lendBookService.selectLendReturnRecordByUserId(map); int totalRecord = lendBookService.getTotalRecord(map); DataGridDataSource<LendReturnList> list = new DataGridDataSource<>(); list.setTotal(totalRecord); list.setRows(lendReturnLists); return list; }
@PostMapping("/lendreturnrecordAll") @LoginRequired public DataGridDataSource<LendReturnList> lendreturnrecordAll(@RequestParam(value = "page", required = false, defaultValue = "1") Integer page, @RequestParam(value = "uid", required = false) Long uid, @RequestParam(value = "rows", required = false, defaultValue = "5") Integer rows, HttpSession session) throws ParseException {
PageBean pageBean = new PageBean(page, rows); Map<String, Object> map = new HashMap<>();
|
——————————PayStart——————————
项目链接:
https://javayms.github.io?id=421422272105200bl
https://javayms.pages.dev?id=421422272105200bl