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






基于javaweb的SpringBoot图书馆借阅管理系统(java+springboot+bootstrap+html+maven+mysql)
项目介绍
本项目分为管理员与学生两种角色, 管理员角色包含以下功能: 登录,图书查询,加入购物车,用户管理,添加用户,角色管理,管理权限,图书管理,进行还书等功能。
学生角色包含以下功能: 登录页面,查看图书列表,好看要预定的图书,开始借阅等功能。
1 2 3 4 5 6 7
| 管理员: admin 123456
用户: user1 123456 user2 123456 user3 123456
|
- 后端:SpringBoot 2. 前端:HTML+CSS+JavaScript+jquery+bootstrap
使用说明
运行项目,输入localhost:8080/ 登录
——————————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 40 41 42 43 44
| @Controller @RequestMapping("/admin/user") public class UserController extends BaseController {
@Autowired private IUserService userService; @Autowired private IRoleService roleService;
@RequestMapping(value = { "/", "/index" }) public String index() { return "admin/user/index"; }
@RequestMapping(value = { "/list" }) @ResponseBody public Page<User> list() { SimpleSpecificationBuilder<User> builder = new SimpleSpecificationBuilder<User>(); String searchText = request.getParameter("searchText"); if(StringUtils.isNotBlank(searchText)){ builder.add("nickName", Operator.likeAll.name(), searchText); } Page<User> page = userService.findAll(builder.generateSpecification(), getPageRequest()); return page; } @RequestMapping(value = "/add", method = RequestMethod.GET) public String add(ModelMap map) { return "admin/user/form"; }
@RequestMapping(value = "/edit/{id}", method = RequestMethod.GET) public String edit(@PathVariable Integer id,ModelMap map) { User user = userService.find(id); map.put("user", user); return "admin/user/form"; } @RequestMapping(value= {"/edit"} ,method = RequestMethod.POST) @ResponseBody public JsonResult edit(User user,ModelMap map){ try {
|
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
|
@RequestMapping(value = { "/findlist" }) @ResponseBody public Page<Book> findList() { SimpleSpecificationBuilder<Book> builder = new SimpleSpecificationBuilder<Book>(); String bookName = request.getParameter("inputBookName"); String bookAuthor = request.getParameter("inputAuthor"); String bookPress = request.getParameter("inputPublication"); if(StringUtils.isNotBlank(bookName)){ builder.add("bookName", Operator.likeAll.name(), bookName); } if(StringUtils.isNotBlank(bookAuthor)){ builder.add("bookAuthor", Operator.likeAll.name(), bookAuthor); } if(StringUtils.isNotBlank(bookPress)){ builder.add("bookPress", Operator.likeAll.name(), bookPress); } Page<Book> page = bookService.findAll(builder.generateSpecification(), getPageRequest()); return page; } }
|
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
|
@Controller @RequestMapping("/web/books") public class BookController extends BaseController{ @Autowired private IBookService bookService; @Autowired private IBorrowBookService borrowBookService;
@RequestMapping("/index") public String index() { return "/admin/books/index"; }
|
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 53
| @RequestMapping(value = { "/returnBookList/{id}" },method = RequestMethod.POST) @ResponseBody public String ReturnBookList(@PathVariable String id,ModelMap map) { BorrowBook[] borrowBooks=borrowBookService.findByUserId(Integer.parseInt(id)); Book[] books=new Book[borrowBooks.length]; Date date=null; for(int i=0;i<books.length;i++) { books[i]=bookService.findByBookId(borrowBooks[i].getBookId()); } Map<String,Object> resultMap=new HashMap(); resultMap.put("borrowBooks", borrowBooks); resultMap.put("books", books); Gson gson=new Gson(); String jsonStr = gson.toJson(resultMap); return jsonStr; }
@RequestMapping(value = {"/returnBook/{borrowlist}"}, method = RequestMethod.POST) @ResponseBody public JsonResult returnBook(@PathVariable String borrowlist) {
Gson gson=new Gson(); BorrowList mBorrowList=gson.fromJson(borrowlist,BorrowList.class); BorrowBook[] borrowBook=new BorrowBook[mBorrowList.getBooklist().length]; Book[] book=new Book[mBorrowList.getBooklist().length]; int i=0; while(i<mBorrowList.getBooklist().length) { borrowBook[i]=new BorrowBook(); book[i]=new Book(); borrowBook[i].setUserId(mBorrowList.getId()); borrowBook[i].setBookId(mBorrowList.getBooklist()[i]); book[i]=bookService.findByBookId(mBorrowList.getBooklist()[i]); book[i].setCurrentInventory(book[i].getCurrentInventory()+1); bookService.saveOrUpdate(book[i]); borrowBookService.deletByUserIdAndBookId(borrowBook[i].getUserId(), borrowBook[i].getBookId());; i++; } i=0; return JsonResult.success(); }
|
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
| map.put("list", list); return "admin/resource/form"; }
@RequestMapping(value = "/edit/{id}", method = RequestMethod.GET) public String edit(@PathVariable Integer id,ModelMap map) { Resource resource = resourceService.find(id); map.put("resource", resource); List<Resource> list = resourceService.findAll(); map.put("list", list); return "admin/resource/form"; } @RequestMapping(value= {"/edit"}, method = RequestMethod.POST) @ResponseBody public JsonResult edit(Resource resource,ModelMap map){ try { resourceService.saveOrUpdate(resource); } catch (Exception e) { return JsonResult.failure(e.getMessage()); } return JsonResult.success(); } @RequestMapping(value = "/delete/{id}", method = RequestMethod.POST) @ResponseBody public JsonResult delete(@PathVariable Integer id,ModelMap map) { try { resourceService.delete(id); } catch (Exception e) { e.printStackTrace(); return JsonResult.failure(e.getMessage()); } return JsonResult.success(); } }
|
——————————PayStart——————————
项目链接:
https://javayms.github.io?id=231122522008200oj
https://javayms.pages.dev?id=231122522008200oj