当前位置:   article > 正文

基于javaweb+mysql的springboot图书馆借阅管理系统(java+springboot+bootstrap+html+maven+mysql)_图书管理系统javaweb

图书管理系统javaweb

基于javaweb+mysql的springboot图书馆借阅管理系统(java+springboot+bootstrap+html+maven+mysql)

私信源码获取及调试交流

运行环境

Java≥8、MySQL≥5.7

开发工具

eclipse/idea/myeclipse/sts等均可配置运行

适用

课程设计,大作业,毕业设计,项目练习,学习演示等

功能说明

基于javaweb的SpringBoot图书馆借阅管理系统(java+springboot+bootstrap+html+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版本;

技术栈

  1. 后端:SpringBoot 2. 前端:HTML+CSS+JavaScript+jquery+bootstrap

使用说明

运行项目,输入localhost:8080/ 登录

public String index() {

return "/admin/books/index";

/**

* 添加图书

* @parameter

* @return addform页面

*/

@RequestMapping(value = {"/addBook"}, method = RequestMethod.GET)

public String addBook() {

return "admin/books/addform";

/**

* 删除图书

* @parameter 图书id,数据集

* @return JsonResult 是否成功
  • 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

e.printStackTrace();

return JsonResult.failure(e.getMessage());

return JsonResult.success();

/**

* 借书

* @parameter Json类型的借书表,数据集

* @return JsonResult

*/

@RequestMapping(value = { "/borrowlist/{borrowlist}" },method = RequestMethod.POST)

@ResponseBody

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21

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 {

userService.delete(id);

} catch (Exception e) {

e.printStackTrace();

return JsonResult.failure(e.getMessage());

return JsonResult.success();

@RequestMapping(value = "/grant/{id}", method = RequestMethod.GET)

public String grant(@PathVariable Integer id, ModelMap 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
@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());

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
* 借书

* @parameter Json类型的借书表,数据集

* @return JsonResult

*/

@RequestMapping(value = { "/borrowlist/{borrowlist}" },method = RequestMethod.POST)

@ResponseBody

public JsonResult borrowList(@PathVariable String borrowlist,ModelMap map) {

if(!borrowlist.equals("undefine"))

Gson gson=new Gson();

BorrowList mBorrowList=gson.fromJson(borrowlist,BorrowList.class);

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20

return JsonResult.failure("库存不足请重新选择图书!");

i++;

i=0;

return JsonResult.success();

}else

return JsonResult.failure("未选择要借阅的书籍!");

/**

* 还书表

* @parameter 借书用户id

* @return String 借书表信息和书籍信息

*/

@RequestMapping(value = { "/returnBookList/{id}" },method = RequestMethod.POST)

@ResponseBody

  • 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
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

  • 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

return "admin/user/grant";

@ResponseBody

@RequestMapping(value = "/grant/{id}", method = RequestMethod.POST)

public JsonResult grant(@PathVariable Integer id,String[] roleIds, ModelMap map) {

try {

userService.grant(id,roleIds);

} catch (Exception e) {

e.printStackTrace();

return JsonResult.failure(e.getMessage());

return JsonResult.success();

资源管理控制层:

@Controller

@RequestMapping("/admin/resource")

  • 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

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

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();

/**

* 修改图书响应请求

* @parameter 修改的图书id,数据集

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23

List<Role> roles = roleService.findAll();

map.put("roles", roles);

return "admin/user/grant";

@ResponseBody

@RequestMapping(value = "/grant/{id}", method = RequestMethod.POST)

public JsonResult grant(@PathVariable Integer id,String[] roleIds, ModelMap map) {

try {

userService.grant(id,roleIds);

} catch (Exception e) {

e.printStackTrace();

return JsonResult.failure(e.getMessage());

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
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();

  • 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

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)

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
@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());

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22

public Page<Book> list() {

SimpleSpecificationBuilder<Book> builder = new SimpleSpecificationBuilder<Book>();

String searchText = request.getParameter("searchText");

if(StringUtils.isNotBlank(searchText)){

builder.add("bookName", Operator.likeAll.name(), searchText);

Page<Book> page = bookService.findAll(builder.generateSpecification(), getPageRequest());

return page;

/**

* 查询图书

* @parameter

* @return Page<Book>

*/

@RequestMapping(value = { "/findlist" })
  • 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
bookService.saveOrUpdate(book[i]);

borrowBookService.save(borrowBook[i]);

}else

return JsonResult.failure("您已经借阅该书!");

}else

return JsonResult.failure("库存不足请重新选择图书!");

i++;

i=0;

return JsonResult.success();

}else

return JsonResult.failure("未选择要借阅的书籍!");

/**

* 还书表

* @parameter 借书用户id

  • 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

List<Resource> list = resourceService.findAll();

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";

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21

请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述

声明:本文内容由网友自发贡献,转载请注明出处:【wpsshop博客】
推荐阅读
相关标签
  

闽ICP备14008679号