源码获取:俺的博客首页 "资源" 里下载!
使用jsp+servlet、layui、mysql完成的图书馆系统,包含用户图书借阅、图书管理员、系统管理员界面,功能齐全。
开发工具为eclipse/IDEA,环境java8,tomcat9.0+,mysql为5.7(mysql8也行)
项目详细介绍
本图书管理系统总体上分为前台页面显示和后台管理。
前台页面(即本书图书管理系统的首页)实现了公告的显示,图书查询,留言建议三大主要功能,有读者规则查看功能,师生们可以看到图书管理人员发布的最新公告信息,并可以查询自己感兴趣的图书,查看留言提议,用户登录后还有个人资料修改、个人借阅信息查询、个人违章信息查询等功能,也可以给学校的图书管理人员留言提议。
后台的页面则集成了图书管理中所需的功能,分成图书管理人员和系统管理人员,平时管理人员的工作都是在后台中完成的。前台是为了师生显示的。相对应的后台是针对学校图书管理人员,后台的页面都加密,如果不正常登录是进入不了后台管理页面的,后台图书管理人员功能包括:借阅图书、归还图书、借书记录显示与查找、还书记录显示与查找、公告增删改查;后台系统管理员功能包括:对书籍的增删改查、对书籍分类的增删改、对借阅证的增删改查、对借阅信息的显示与查找、对借阅规则的增删改、对图书管理员的增删改、对近期借阅书籍数量的折线图显示,以及对这些表格数据进行Excel表格的输出
共包含三个大模块:用户、图书管理员、系统管理员
1. 查看公告:能看到图书管理员发布的公告信息。
2. 图书查看:分页显示,能看到图书总览,能通过图书编号、图书名称、作者、存放位置、图书描述进行模糊查询
3. 个人违章信息(登录后):个人历史违章信息与查询
4. 图书馆读者留言(登录后):对图书馆的建议,或对书籍的评价
5. 查看借阅规则:不同的规则有不同的借阅限定数量、限定时间、超期费用
6. 个人信息(登录后):对个人信息的查看与登录密码的修改
7. 个人借阅信息(登录后):对个人借阅记录的分页查看与查询
1. 借还图书:帮助用户借阅图书,并判断符不符合借阅规则、返还图书时判断有没有超期,超期则输出超期费用再归还
2. 借阅报表:分页显示所有借阅记录、能进行查询和输出结果到excel公告管理:能添加编辑和删除公告
3. 还书报表:分页显示所有未还的书籍,能通过借阅证号、图书编号、借阅日期、截止日期等条件进行模糊查询
4. 个人信息修改:修改个人信息、密码等
1. 书籍管理:分页,新添图书,设置图书各种信息,编辑删除,通过编号、书名、作者、描述等进行搜索,输出结果到excel,并且能查看该书籍被谁借阅过。
2. 分类管理:分页显示,增删改书籍分类,书籍分类方便查阅整理
3. 借阅证管理:分页显示所有借阅证,增删改查用户借阅证,查看该借阅证所有的借阅记录
4. 借阅规则管理:能显示、编辑、删除所有借阅规则,借阅规则将决定该图书证能借阅什么图书馆的图书,能借多少本,能借多久以及超期每天的费用。
5. 借阅信息查询:分页显示,能条件查询超期没还的,根据编号、借阅证号、书籍编号、借阅日期等进行模糊查询,输出结果到excel等,系统管理员只能查询,不能增删改借阅信息,这个操作由图书管理员操作。
6. 图书管理员管理:对图书管理员进行增删改操作,但是不能修改原来的账号
7. 图书借阅统计:通过折线图将图书馆近30天的每天借阅书籍数量直观的显示出来。
共有十张数据库表,书籍表、借书记录表、留言表、系统管理员表、借阅证表、图书管理管理员表书籍分类表、图书馆表、借阅规则表、公告表
- 书籍表
- 编号、姓名、作者、存放的图书馆、分类编号、存放位置、是否借出、书籍描述
- 借书记录表
- 编号、借阅证编号、书籍编号、借书日期、限制日期、归还日期、违规描述、处理人编号
- 留言表
- 编号、借阅证编号、留言内容、留言日期
- 系统管理员表
- 账号、密码
- 借阅证表
- 编号、密码、借阅者姓名、规则编号、状态(丢失、可用)
- 图书管理员表
- 编号、姓名、账号、密码、邮箱
- 书籍分类表
- 编号、分类名、分类描述
- 图书馆表
- 编号、图书馆名、描述
- 规则表
- 编号、限制借阅数量、限制借阅天数、图书超期每天费用
- 公告表
- 编号、标题、公告内容、发布日期
1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。
2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA;
3.tomcat环境:Tomcat 9.x版本,注:tomcat9.0以下会有问题;
4.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS;
5.是否Maven项目: 否;查看源码目录中是否包含pom.xml;若包含,则为maven项目,否则为非maven项目
6.数据库:MySql 5.7版本,(mysql8也行)
1. 后端:JSP+Servlet
2. 前端:jsp+layui+bootstrap+jQuery
1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件;
2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;若为maven项目,导入成功后请执行maven clean;maven install命令,配置tomcat,然后运行;
3. 将项目中src/javabean/Base.java和JDBCBean.java配置文件中的数据库配置改为自己的配置;
4. 运行项目,输入localhost:8080/xxx 登录
5. 用户账号密码:1805010219 1234
图书管理员账号密码:root 1234
系统管理员账号密码:admin admin
@Controller
public class ReaderController {
@Autowired
private ReaderInfoService readerInfoService;
@Autowired
private LoginService loginService;
@Autowired
private ReaderCardService readerCardService;
private ReaderInfo getReaderInfo(long readerId, String name, String sex, String birth, String address, String phone) {
ReaderInfo readerInfo = new ReaderInfo();
Date date = new Date();
try {
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
date = df.parse(birth);
} catch (ParseException e) {
e.printStackTrace();
}
readerInfo.setAddress(address);
readerInfo.setName(name);
readerInfo.setReaderId(readerId);
readerInfo.setPhone(phone);
readerInfo.setSex(sex);
readerInfo.setBirth(date);
return readerInfo;
}
@RequestMapping("allreaders.html")
public ModelAndView allBooks() {
ArrayList readers = readerInfoService.readerInfos();
ModelAndView modelAndView = new ModelAndView("admin_readers");
modelAndView.addObject("readers", readers);
return modelAndView;
}
@RequestMapping("reader_delete.html")
public String readerDelete(HttpServletRequest request, RedirectAttributes redirectAttributes) {
long readerId = Long.parseLong(request.getParameter("readerId"));
if (readerInfoService.deleteReaderInfo(readerId) && readerCardService.deleteReaderCard(readerId)) {
redirectAttributes.addFlashAttribute("succ", "删除成功!");
} else {
redirectAttributes.addFlashAttribute("error", "删除失败!");
}
return "redirect:/allreaders.html";
}
@RequestMapping("/reader_info.html")
public ModelAndView toReaderInfo(HttpServletRequest request) {
ReaderCard readerCard = (ReaderCard) request.getSession().getAttribute("readercard");
ReaderInfo readerInfo = readerInfoService.getReaderInfo(readerCard.getReaderId());
ModelAndView modelAndView = new ModelAndView("reader_info");
modelAndView.addObject("readerinfo", readerInfo);
return modelAndView;
}
@RequestMapping("reader_edit.html")
public ModelAndView readerInfoEdit(HttpServletRequest request) {
long readerId = Long.parseLong(request.getParameter("readerId"));
ReaderInfo readerInfo = readerInfoService.getReaderInfo(readerId);
ModelAndView modelAndView = new ModelAndView("admin_reader_edit");
modelAndView.addObject("readerInfo", readerInfo);
return modelAndView;
}
@RequestMapping("reader_edit_do.html")
public String readerInfoEditDo(HttpServletRequest request, String name, String sex, String birth, String address, String phone, RedirectAttributes redirectAttributes) {
long readerId = Long.parseLong(request.getParameter("readerId"));
ReaderInfo readerInfo = getReaderInfo(readerId, name, sex, birth, address, phone);
if (readerInfoService.editReaderInfo(readerInfo) && readerInfoService.editReaderCard(readerInfo)) {
redirectAttributes.addFlashAttribute("succ", "读者信息修改成功!");
} else {
redirectAttributes.addFlashAttribute("error", "读者信息修改失败!");
}
return "redirect:/allreaders.html";
}
@RequestMapping("reader_add.html")
public ModelAndView readerInfoAdd() {
return new ModelAndView("admin_reader_add");
}
@RequestMapping("reader_add_do.html")
public String readerInfoAddDo(String name, String sex, String birth, String address, String phone, String password, RedirectAttributes redirectAttributes) {
ReaderInfo readerInfo = getReaderInfo(0, name, sex, birth, address, phone);
long readerId = readerInfoService.addReaderInfo(readerInfo);
readerInfo.setReaderId(readerId);
if (readerId > 0 && readerCardService.addReaderCard(readerInfo, password)) {
redirectAttributes.addFlashAttribute("succ", "添加读者信息成功!");
} else {
redirectAttributes.addFlashAttribute("succ", "添加读者信息失败!");
}
return "redirect:/allreaders.html";
}
@RequestMapping("reader_info_edit.html")
public ModelAndView readerInfoEditReader(HttpServletRequest request) {
ReaderCard readerCard = (ReaderCard) request.getSession().getAttribute("readercard");
ReaderInfo readerInfo = readerInfoService.getReaderInfo(readerCard.getReaderId());
ModelAndView modelAndView = new ModelAndView("reader_info_edit");
modelAndView.addObject("readerinfo", readerInfo);
return modelAndView;
}
@RequestMapping("reader_edit_do_r.html")
public String readerInfoEditDoReader(HttpServletRequest request, String name, String sex, String birth, String address, String phone, RedirectAttributes redirectAttributes) {
ReaderCard readerCard = (ReaderCard) request.getSession().getAttribute("readercard");
ReaderInfo readerInfo = getReaderInfo(readerCard.getReaderId(), name, sex, birth, address, phone);
if (readerInfoService.editReaderInfo(readerInfo) && readerInfoService.editReaderCard(readerInfo)) {
ReaderCard readerCardNew = loginService.findReaderCardByReaderId(readerCard.getReaderId());
request.getSession().setAttribute("readercard", readerCardNew);
redirectAttributes.addFlashAttribute("succ", "信息修改成功!");
} else {
redirectAttributes.addFlashAttribute("error", "信息修改失败!");
}
return "redirect:/reader_info.html";
}
}
@Controller
public class LendController {
@Autowired
private LendService lendService;
@Autowired
private BookService bookService;
@RequestMapping("/deletebook.html")
public String deleteBook(HttpServletRequest request, RedirectAttributes redirectAttributes) {
long bookId = Long.parseLong(request.getParameter("bookId"));
if (bookService.deleteBook(bookId)) {
redirectAttributes.addFlashAttribute("succ", "图书删除成功!");
} else {
redirectAttributes.addFlashAttribute("error", "图书删除失败!");
}
return "redirect:/admin_books.html";
}
@RequestMapping("/lendlist.html")
public ModelAndView lendList(HttpServletRequest request) {
ModelAndView modelAndView = new ModelAndView("admin_lend_list");
modelAndView.addObject("list", lendService.lendList());
return modelAndView;
}
@RequestMapping("/mylend.html")
public ModelAndView myLend(HttpServletRequest request) {
ReaderCard readerCard = (ReaderCard) request.getSession().getAttribute("readercard");
ModelAndView modelAndView = new ModelAndView("reader_lend_list");
modelAndView.addObject("list", lendService.myLendList(readerCard.getReaderId()));
return modelAndView;
}
@RequestMapping("/deletelend.html")
public String deleteLend(HttpServletRequest request, RedirectAttributes redirectAttributes) {
long serNum = Long.parseLong(request.getParameter("serNum"));
if (lendService.deleteLend(serNum) > 0) {
redirectAttributes.addFlashAttribute("succ", "记录删除成功!");
} else {
redirectAttributes.addFlashAttribute("error", "记录删除失败!");
}
return "redirect:/lendlist.html";
}
@RequestMapping("/lendbook.html")
public String bookLend(HttpServletRequest request, RedirectAttributes redirectAttributes) {
long bookId = Long.parseLong(request.getParameter("bookId"));
long readerId = ((ReaderCard) request.getSession().getAttribute("readercard")).getReaderId();
if (lendService.lendBook(bookId, readerId)) {
redirectAttributes.addFlashAttribute("succ", "图书借阅成功!");
} else {
redirectAttributes.addFlashAttribute("succ", "图书借阅成功!");
}
return "redirect:/reader_books.html";
}
@RequestMapping("/returnbook.html")
public String bookReturn(HttpServletRequest request, RedirectAttributes redirectAttributes) {
long bookId = Long.parseLong(request.getParameter("bookId"));
long readerId = ((ReaderCard) request.getSession().getAttribute("readercard")).getReaderId();
if (lendService.returnBook(bookId, readerId)) {
redirectAttributes.addFlashAttribute("succ", "图书归还成功!");
} else {
redirectAttributes.addFlashAttribute("error", "图书归还失败!");
}
return "redirect:/reader_books.html";
}
}
@Controller
public class BookController {
@Autowired
private BookService bookService;
@Autowired
private LendService lendService;
private Date getDate(String pubstr) {
try {
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
return df.parse(pubstr);
} catch (ParseException e) {
e.printStackTrace();
return new Date();
}
}
@RequestMapping("/queryBook.html")
public ModelAndView queryBookDo(String searchWord) {
if (bookService.matchBook(searchWord)) {
ArrayList books = bookService.queryBook(searchWord);
ModelAndView modelAndView = new ModelAndView("admin_books");
modelAndView.addObject("books", books);
return modelAndView;
} else {
return new ModelAndView("admin_books", "error", "没有匹配的图书");
}
}
@RequestMapping("/reader_querybook_do.html")
public ModelAndView readerQueryBookDo(String searchWord) {
if (bookService.matchBook(searchWord)) {
ArrayList books = bookService.queryBook(searchWord);
ModelAndView modelAndView = new ModelAndView("reader_books");
modelAndView.addObject("books", books);
return modelAndView;
} else {
return new ModelAndView("reader_books", "error", "没有匹配的图书");
}
}
@RequestMapping("/admin_books.html")
public ModelAndView adminBooks() {
ArrayList books = bookService.getAllBooks();
ModelAndView modelAndView = new ModelAndView("admin_books");
modelAndView.addObject("books", books);
return modelAndView;
}
@RequestMapping("/book_add.html")
public ModelAndView addBook() {
return new ModelAndView("admin_book_add");
}
@RequestMapping("/book_add_do.html")
public String addBookDo(@RequestParam(value = "pubstr") String pubstr, Book book, RedirectAttributes redirectAttributes) {
book.setPubdate(getDate(pubstr));
if (bookService.addBook(book)) {
redirectAttributes.addFlashAttribute("succ", "图书添加成功!");
} else {
redirectAttributes.addFlashAttribute("succ", "图书添加失败!");
}
return "redirect:/admin_books.html";
}
@RequestMapping("/updatebook.html")
public ModelAndView bookEdit(HttpServletRequest request) {
long bookId = Long.parseLong(request.getParameter("bookId"));
Book book = bookService.getBook(bookId);
ModelAndView modelAndView = new ModelAndView("admin_book_edit");
modelAndView.addObject("detail", book);
return modelAndView;
}
@RequestMapping("/book_edit_do.html")
public String bookEditDo(@RequestParam(value = "pubstr") String pubstr, Book book, RedirectAttributes redirectAttributes) {
book.setPubdate(getDate(pubstr));
if (bookService.editBook(book)) {
redirectAttributes.addFlashAttribute("succ", "图书修改成功!");
} else {
redirectAttributes.addFlashAttribute("error", "图书修改失败!");
}
return "redirect:/admin_books.html";
}
@RequestMapping("/admin_book_detail.html")
public ModelAndView adminBookDetail(HttpServletRequest request) {
long bookId = Long.parseLong(request.getParameter("bookId"));
Book book = bookService.getBook(bookId);
ModelAndView modelAndView = new ModelAndView("admin_book_detail");
modelAndView.addObject("detail", book);
return modelAndView;
}
@RequestMapping("/reader_book_detail.html")
public ModelAndView readerBookDetail(HttpServletRequest request) {
long bookId = Long.parseLong(request.getParameter("bookId"));
Book book = bookService.getBook(bookId);
ModelAndView modelAndView = new ModelAndView("reader_book_detail");
modelAndView.addObject("detail", book);
return modelAndView;
}
@RequestMapping("/admin_header.html")
public ModelAndView admin_header() {
return new ModelAndView("admin_header");
}
@RequestMapping("/reader_header.html")
public ModelAndView reader_header() {
return new ModelAndView("reader_header");
}
@RequestMapping("/reader_books.html")
public ModelAndView readerBooks(HttpServletRequest request) {
ArrayList books = bookService.getAllBooks();
ReaderCard readerCard = (ReaderCard) request.getSession().getAttribute("readercard");
ArrayList myAllLendList = lendService.myLendList(readerCard.getReaderId());
ArrayList myLendList = new ArrayList<>();
for (Lend lend : myAllLendList) {
// 是否已归还
if (lend.getBackDate() == null) {
myLendList.add(lend.getBookId());
}
}
ModelAndView modelAndView = new ModelAndView("reader_books");
modelAndView.addObject("books", books);
modelAndView.addObject("myLendList", myLendList);
return modelAndView;
}
}
源码获取:俺的博客首页 "资源" 里下载!