温馨提示:本系统源码获取方式见文章末尾
Java精选项目大全:《Java项目精选|Java毕业设计项目源码》
图书管理作为计算机应用的一个分支,有着手工管理无法比拟的优点,如检索迅速、查找方便、可靠性高、存储量大、保密性好、寿命长、成本低等,这些优点能够极大地提高图书管理的效率。因此,开发一套能够为用户提供充足的信息和快捷的查询手段的图书管理系统是非常必要的。
本系统实现了图书管理、借阅管理、用户管理、公告管理、个人中心等功能,界面友好、操作容易、维护简单、能够处理大量数据,同时保持数据的完整性、安全性,符合高校图书管理系统的要求。
JDK1.8 + Maven3 + MySQL5.7
本系统主要用于高校图书管理,使用人群为系统管理员、普通读者。
系统管理员:
普通读者:
数据库设计见图书管理系统设计与实现(SpringBoot+Mysql+HTML
,源码包获取方式看本文第十章节
。
下载本项目源码并导入到开发工具后(下图为导入到IDEA中的目录结构),项目的目录结构如下图所示:
部分代码:
DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta charset="utf-8">
<link href="javaex/pc/css/icomoon.css" rel="stylesheet" />
<link href="javaex/pc/css/animate.css" rel="stylesheet" />
<link href="javaex/pc/css/common.css" rel="stylesheet" />
<link href="javaex/pc/css/skin/tina.css" rel="stylesheet" />
<script src="javaex/pc/lib/jquery-1.7.2.min.js">script>
<script src="javaex/pc/js/common.js">script>
<script src="javaex/pc/js/javaex.min.js">script>
<script src="javaex/pc/js/javaex-formVerify.js">script>
<title>图书管理系统-首页title>
<style>
style>
head>
<body>
<div class="admin-navbar">
<div class="admin-container-fluid clear">
<div class="admin-logo">图书管理系统div>
<ul class="admin-navbar-nav fr">
<li><input id="index_role" hidden /> <a href="javascript:;">欢迎您,<span
id="login_user">span>a>
<ul class="dropdown-menu" style="right: 10px;">
<li><a href="logout">退出当前账号a>li>
ul>li>
ul>
div>
div>
<div class="admin-mian" style="margin-bottom: 50px;">
<div class="admin-aside admin-aside-fixed">
<div id="admin-toc" class="admin-toc">
<div class="menu-box">
<div id="menu" class="menu">
<ul id="adminMenu" style="display: none;">
<li class="menu-item hover"><a
href="javascript:page('welcome');"><i class="icon-home2">i>首页a>
li>
<li class="menu-item"><a href="javascript:;">图书管理<i
class="icon-keyboard_arrow_left">i>a>
<ul>
<li><a href="javascript:page('book/book-list');">图书列表a>li>
<li><a href="javascript:page('book/book-add');">图书上架a>li>
ul>li>
<li class="menu-item"><a href="javascript:;">借阅管理<i
class="icon-keyboard_arrow_left">i>a>
<ul>
<li><a href="javascript:page('borrow/book-list');">借阅图书a>li>
<li><a href="javascript:page('borrow/back');">归还图书a>li>
ul>li>
<li class="menu-item"><a href="javascript:;">用户管理<i
class="icon-keyboard_arrow_left">i>a>
<ul>
<li><a href="javascript:page('user/user-list');">用户列表a>li>
<li><a href="javascript:page('user/user-add');">用户添加a>li>
ul>li>
<li class="menu-item"><a href="javascript:;">公告管理<i
class="icon-keyboard_arrow_left">i>a>
<ul>
<li><a href="javascript:page('notice/notice-list');">公告列表a>li>
<li><a href="javascript:page('notice/notice-add');">公告发布a>li>
ul>li>
<li class="menu-item"><a href="javascript:;">个人中心<i
class="icon-keyboard_arrow_left">i>a>
<ul>
<li><a href="javascript:page('my/my-info');">个人信息详情a>li>
<li><a href="javascript:page('my/my-update');">个人信息修改a>li>
ul>li>
ul>
<ul id="userMenu" style="display: none;">
<li class="menu-item hover"><a
href="javascript:page('welcome');"><i class="icon-home2">i>首页a>
li>
<li class="menu-item"><a href="javascript:;">借阅管理<i
class="icon-keyboard_arrow_left">i>a>
<ul>
<li><a href="javascript:page('borrow/book-list');">借阅图书a>li>
<li><a href="javascript:page('borrow/back');">归还图书a>li>
ul>li>
<li class="menu-item"><a href="javascript:;">公告管理<i
class="icon-keyboard_arrow_left">i>a>
<ul>
<li><a href="javascript:page('notice/notice-list');">公告列表a>li>
ul>li>
<li class="menu-item"><a href="javascript:;">个人中心<i
class="icon-keyboard_arrow_left">i>a>
<ul>
<li><a href="javascript:page('my/my-info');">个人信息详情a>li>
<li><a href="javascript:page('my/my-update');">个人信息修改a>li>
ul>li>
ul>
div>
div>
div>
div>
<div class="admin-markdown">
<iframe id="page" src="welcome">iframe>
div>
div>
<div class="admin-footer" style="position: fixed; bottom: 0;">
<div class="admin-container-fluid clear"
style="line-height: 50px; text-align: center;">【IT学长】div>
div>
body>
<script>
var hightUrl = "xxxx";
javaex.menu({
id : "menu",
isAutoSelected : true,
key : "",
url : hightUrl
});
$(function() {
// 设置左侧菜单高度
setMenuHeight();
});
/**
* 设置左侧菜单高度
*/
function setMenuHeight() {
var height = document.documentElement.clientHeight - $("#admin-toc").offset().top;
height = height - 10;
$("#admin-toc").css("height", height+"px");
}
// 控制页面载入
function page(url) {
$("#page").attr("src", url);
}
$(document).ready(function(){
// 页面一加载, 读取登录用户信息
$.get("user/currUser", function(data){
var user = data.data;
var userId = user.id;
console.log("user",user);
if (userId >0) {
$("#login_user").text(user.username+"["+user.ident+"]");
$("#index_role").val(user.isAdmin);
if(user.isAdmin==0){
$("#adminMenu").css("display",'block');
$("#userMenu").css("display",'none');
}
else{
$("#adminMenu").css("display",'none');
$("#userMenu").css("display",'block');
}
}else {
// 找不到用户, 不可进行借阅操作
javaex.message({
content : "登录信息已失效, 请登录后借阅",
type : "error"
});
}
});
});
script>
html>
图书上架:
图书修改:
部分源码:
package com.book.manager.controller;
import com.book.manager.entity.Book;
import com.book.manager.service.BookService;
import com.book.manager.service.BorrowService;
import com.book.manager.util.R;
import com.book.manager.util.http.CodeEnum;
import com.book.manager.util.ro.PageIn;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
/**
* @Description 用户管理
* @Date 2022/9/4 16:35
*/
@Api(tags = "图书管理")
@RestController
@RequestMapping("/book")
public class BookController {
@Autowired
private BookService bookService;
@Autowired
private BorrowService borrowService;
@ApiOperation("图书搜索列表")
@PostMapping("/list")
public R getBookList(@RequestBody PageIn pageIn) {
if (pageIn == null) {
return R.fail(CodeEnum.PARAM_ERROR);
}
return R.success(CodeEnum.SUCCESS,bookService.getBookList(pageIn));
}
@ApiOperation("添加图书")
@PostMapping("/add")
public R addBook(@RequestBody Book book) {
return R.success(CodeEnum.SUCCESS,bookService.addBook(book));
}
@ApiOperation("编辑图书")
@PostMapping("/update")
public R modifyBook(@RequestBody Book book) {
return R.success(CodeEnum.SUCCESS,bookService.updateBook(book));
}
@ApiOperation("图书详情")
@GetMapping("/detail")
public R bookDetail(Integer id) {
return R.success(CodeEnum.SUCCESS,bookService.findBookById(id));
}
@ApiOperation("图书详情 根据ISBN获取")
@GetMapping("/detailByIsbn")
public R bookDetailByIsbn(String isbn) {
return R.success(CodeEnum.SUCCESS,bookService.findBookByIsbn(isbn));
}
@ApiOperation("删除图书")
@GetMapping("/delete")
public R delBook(Integer id) {
bookService.deleteBook(id);
borrowService.deleteBorrowByBookId(id);
return R.success(CodeEnum.SUCCESS);
}
}
借阅图书:
归还图书:
部分源码:
package com.book.manager.service;
import cn.hutool.core.bean.BeanUtil;
import com.book.manager.dao.BookMapper;
import com.book.manager.dao.BorrowMapper;
import com.book.manager.dao.UsersMapper;
import com.book.manager.entity.Book;
import com.book.manager.entity.Borrow;
import com.book.manager.entity.Users;
import com.book.manager.repos.BookRepository;
import com.book.manager.repos.BorrowRepository;
import com.book.manager.util.consts.Constants;
import com.book.manager.util.vo.BookOut;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Date;
import java.util.List;
import java.util.Optional;
/**
* @Description 借阅管理
* @Date 2022/9/4 16:35
* @Author by 【IT学长】
*/
@Service
public class BorrowService {
@Autowired
private BorrowRepository borrowRepository;
@Autowired
private BorrowMapper borrowMapper;
@Autowired
private BookService bookService;
@Autowired
private UserService userService;
/**
* 添加
*/
@Transactional
public Integer addBorrow(Borrow borrow) {
Book book = bookService.findBook(borrow.getBookId());
Users users = userService.findUserById(borrow.getUserId());
// 查询是否已经借阅过该图书
Borrow bor = findBorrowByUserIdAndBookId(users.getId(),book.getId());
if (bor!=null) {
Integer ret = bor.getRet();
if (ret!=null) {
// 已借阅, 未归还 不可再借
if (ret == Constants.NO) {
return Constants.BOOK_BORROWED;
}
}
}
// 库存数量减一
int size = book.getSize();
if (size>0) {
size--;
book.setSize(size);
bookService.updateBook(book);
}else {
return Constants.BOOK_SIZE_NOT_ENOUGH;
}
// 用户可借数量减一
int userSize = users.getSize();
if (userSize>0) {
userSize --;
users.setSize(userSize);
userService.updateUser(users);
}else {
return Constants.USER_SIZE_NOT_ENOUGH;
}
// 添加借阅信息, 借阅默认为未归还状态
borrow.setRet(Constants.NO);
borrowRepository.saveAndFlush(borrow);
// 一切正常
return Constants.OK;
}
/**
* user id查询所有借阅信息
*/
public List<Borrow> findAllBorrowByUserId(Integer userId) {
return borrowRepository.findBorrowByUserId(userId);
}
/**
* user id查询所有 已借阅信息
*/
public List<Borrow> findBorrowsByUserIdAndRet(Integer userId, Integer ret) {
return borrowRepository.findBorrowsByUserIdAndRet(userId,ret);
}
/**
* 详情
*/
public Borrow findById(Integer id) {
Optional<Borrow> optional = borrowRepository.findById(id);
if (optional.isPresent()) {
return optional.get();
}
return null;
}
/**
* 编辑
*/
public boolean updateBorrow(Borrow borrow) {
return borrowMapper.updateBorrow(borrow)>0;
}
/**
* 编辑
*/
public Borrow updateBorrowByRepo(Borrow borrow) {
return borrowRepository.saveAndFlush(borrow);
}
/**
* 根据ID删除
*/
public void deleteBorrow(Integer id) {
borrowRepository.deleteById(id);
}
/**
* 根据book_id删除
*/
public void deleteBorrowByBookId(Integer bookId) {
borrowMapper.deleteBorrowByBookId(bookId);
}
/**
* 查询用户某一条借阅信息
* @param userId 用户id
* @param bookId 图书id
*/
public Borrow findBorrowByUserIdAndBookId(int userId,int bookId) {
return borrowMapper.findBorrowByUserIdAndBookId(userId,bookId);
}
/**
* 归还书籍,
* @param userId 用户Id
* @param bookId 书籍id
*/
@Transactional(rollbackFor = Exception.class)
public void retBook(int userId,int bookId) {
// 用户可借数量加1
Users user = userService.findUserById(userId);
Integer size = user.getSize();
size++;
user.setSize(size);
userService.updateUser(user);
// 书籍库存加1
Book book = bookService.findBook(bookId);
Integer bookSize = book.getSize();
bookSize++;
book.setSize(bookSize);
bookService.updateBook(book);
// 借阅记录改为已归还,删除记录
Borrow borrow = this.findBorrowByUserIdAndBookId(userId, bookId);
this.deleteBorrow(borrow.getId());
}
}
用户列表:
用户添加:
部分源码:
DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.book.manager.dao.UsersMapper">
<resultMap id="BaseResultMap"
type="com.book.manager.entity.Users">
<id column="id" property="id" jdbcType="INTEGER" />
<result column="avatar" property="avatar" jdbcType="VARCHAR" />
<result column="nickname" property="nickname"
jdbcType="VARCHAR" />
<result column="username" property="username"
jdbcType="VARCHAR" />
<result column="password" property="password"
jdbcType="VARCHAR" />
<result column="birthday" property="birthday"
jdbcType="TIMESTAMP" />
<result column="is_admin" property="isAdmin" jdbcType="INTEGER" />
<result column="tel" property="tel" jdbcType="VARCHAR" />
<result column="email" property="email" jdbcType="VARCHAR" />
<result column="address" property="address" jdbcType="VARCHAR" />
<result column="size" property="size" jdbcType="INTEGER" />
resultMap>
<select id="findListByLike" resultMap="BaseResultMap">
select * from users
<where>
<if test="_parameter != null and _parameter != ''">
and `username` like CONCAT('%',#{_parameter},'%') or `nickname` like
CONCAT('%',#{_parameter},'%')
if>
where>
select>
<update id="updateUsers" parameterType="map">
update users
<set>
<if test="avatar != null and avatar != ''">
avatar = #{avatar},
if>
<if test="nickname != null and nickname != ''">
nickname = #{nickname},
if>
<if test="username != null and username != ''">
username = #{username},
if>
<if test="password != null and password != ''">
password = #{password},
if>
<if test="birthday != null">
birthday = #{birthday},
if>
<if test="isAdmin != null">
is_admin = #{isAdmin},
if>
<if test="tel != null and tel != ''">
tel = #{tel},
if>
<if test="email != null and email != ''">
email = #{email},
if>
<if test="address != null and address != ''">
address = #{address},
if>
<if test="size != null">
`size` = #{size},
if>
set>
where id = #{id}
update>
mapper>
公告列表:
公告详情:
部分源码:
package com.book.manager.controller;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import com.book.manager.entity.Notice;
import com.book.manager.entity.Users;
import com.book.manager.service.NoticeService;
import com.book.manager.util.R;
import com.book.manager.util.consts.Constants;
import com.book.manager.util.consts.ConvertUtil;
import com.book.manager.util.http.CodeEnum;
import com.book.manager.util.vo.NoticeOut;
import com.book.manager.util.vo.PageOut;
import com.book.manager.util.vo.UserOut;
import com.book.manager.util.ro.PageIn;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* @Description 公告管理
* @Date 2022/9/4 16:35
* @Author by 【IT学长】
*/
@Api(tags = "公告管理")
@RestController
@RequestMapping("/notice")
public class NoticeController {
@Autowired
private NoticeService noticeService;
@ApiOperation("公告列表")
@PostMapping("/list")
public R getNotices(@RequestBody PageIn pageIn) {
if (pageIn == null) {
return R.fail(CodeEnum.PARAM_ERROR);
}
// 封装分页出参对象
PageInfo<Notice> noticeList = noticeService.getNoticeList(pageIn);
PageOut pageOut = new PageOut();
pageOut.setCurrPage(noticeList.getPageNum());
pageOut.setPageSize(noticeList.getPageSize());
pageOut.setTotal((int) noticeList.getTotal());
List<Notice> outs = new ArrayList<>();
for (Notice notice : noticeList.getList()) {
NoticeOut out = new NoticeOut();
BeanUtils.copyProperties(notice,out);
out.setDate1(DateUtil.format(notice.getDate(),Constants.DATE_FORMAT));
outs.add(out);
}
pageOut.setList(outs);
return R.success(CodeEnum.SUCCESS,pageOut);
}
@ApiOperation("添加公告")
@PostMapping("/addNoticer")
public R addNoticer(@RequestBody Notice notice) {
if (notice == null) {
return R.fail(CodeEnum.PARAM_ERROR);
}
return R.success(CodeEnum.SUCCESS,noticeService.addNotice(notice));
}
@ApiOperation("编辑公告")
@PostMapping("/update")
public R modifyNotice(@RequestBody Notice notice) {
return R.success(CodeEnum.SUCCESS,noticeService.updateNotice(notice));
}
@ApiOperation("公告详情")
@GetMapping("/detail")
public R noticeDetail(Integer id) {
Notice notice = noticeService.findNoticeById(id);
if (notice!=null) {
NoticeOut out = new NoticeOut();
BeanUtils.copyProperties(notice,out);
out.setDate1(DateUtil.format(notice.getDate(),Constants.DATE_FORMAT));
return R.success(CodeEnum.SUCCESS,out);
}
return R.fail(CodeEnum.NOT_FOUND);
}
@ApiOperation("删除公告")
@GetMapping("/delete")
public R delNotice(Integer id) {
noticeService.deleteNotice(id);
return R.success(CodeEnum.SUCCESS);
}
}
个人信息详情:
部分源码:
DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta charset="utf-8">
<link href="../javaex/pc/css/icomoon.css" rel="stylesheet" />
<link href="../javaex/pc/css/animate.css" rel="stylesheet" />
<link href="../javaex/pc/css/common.css" rel="stylesheet" />
<link href="../javaex/pc/css/skin/tina.css" rel="stylesheet" />
<script src="../javaex/pc/lib/jquery-1.7.2.min.js">script>
<script src="../javaex/pc/js/common.js">script>
<script src="../javaex/pc/js/javaex.min.js">script>
<script src="../javaex/pc/js/javaex-formVerify.js">script>
<title>图书管理系统-查询个人信息title>
head>
<style>
style>
<body>
<div class="list-content">
<div class="block">
<div class="banner">
<p class="tab fixed">个人信息p>
div>
<div class="main">
<form id="form">
<div class="unit clear">
<div class="left">
<span class="required">*span>
<p class="subtitle">昵称p>
div>
<div class="right">
<input type="text" class="text" id="nickname" name="nickname"
readonly="readonly" />
div>
div>
<div class="unit clear">
<div class="left">
<span class="required">*span>
<p class="subtitle">用户名p>
div>
<div class="right">
<input type="text" class="text" id="username" name="username"
readonly="readonly" />
div>
div>
<div class="unit clear">
<div class="left">
<span class="required">*span>
<p class="subtitle">密码p>
div>
<div class="right">
<input type="password" class="text" id="password" name="password"
readonly="readonly" />
div>
div>
<div class="unit clear">
<div class="left">
<span class="required">span>
<p class="subtitle">生日p>
div>
<div class="right">
<input type="text" class="text" id="birthday" name="birthday"
readonly="readonly" />
div>
div>
<div class="unit clear">
<div class="left">
<span class="required">span>
<p class="subtitle">电话p>
div>
<div class="right">
<input type="text" class="text" id="tel" name="tel"
readonly="readonly" />
div>
div>
<div class="unit clear">
<div class="left">
<span class="required">span>
<p class="subtitle">身份p>
div>
<div class="right">
<input type="text" class="text" id="ident" name="ident"
readonly="readonly" />
div>
div>
<div class="unit clear">
<div class="left">
<span class="required">span>
<p class="subtitle">邮箱p>
div>
<div class="right">
<input type="text" class="text" id="email" name="email"
readonly="readonly" />
div>
div>
<div class="unit clear">
<div class="left">
<span class="required">span>
<p class="subtitle">地址p>
div>
<div class="right">
<input type="text" class="text" id="address" name="address"
readonly="readonly" />
div>
div>
<div class="unit clear">
<div class="left">
<span class="required">span>
<p class="subtitle">可借数量p>
div>
<div class="right">
<input type="text" class="text" id="size" name="size"
readonly="readonly" />
div>
div>
<br> <br>
form>
div>
div>
div>
<script>
javaex.select({
id : "select",
isSearch : false
});
// 页面加载执行
$(document).ready(function() {
// get读取参数
$.get("../user/currUser", function(data) {
var user = data.data;
$("#nickname").val(user.nickname);
$("#username").val(user.username);
$("#password").val(user.password);
$("#birthday").val(user.birth);
$("#tel").val(user.tel);
$("#email").val(user.email);
$("#address").val(user.address);
$("#size").val(user.size);
$("#ident").val(user.ident);
return false;
});
});
script>
body>
html>
详细运行步骤及常见问题解答请看“图书管理系统设计与实现(SpringBoot+Mysql+HTML)
”源码包中 README.md
文件。
通过第10章节
下载源码包并解压后如下图所示:
本期内容就到这里,感谢你的阅读。获取本系统源码请微信搜索关注下方名片
,回复“20220927
”。关键词一定要输完整、输对哦!!