当前位置:   article > 正文

Java项目:273SSM图书馆管理系统_ssm图书管理项目

ssm图书管理项目

作者主页:夜未央5788

 简介:Java领域优质创作者、Java项目、学习资料、技术互助

文末获取源码

项目介绍

SSM图书馆管理系统,角色:管理员和读者。
管理员角色功能如下:
登录、图书管理、读者管理、公告管理、借阅管理、类型管理、首页、统计分析、图书馆系统、修改密码

读者角色功能如下:
登录、公告管理、借阅管理、修改密码;

由于本程序规模不大,可供课程设计,毕业设计学习演示之用

环境需要

1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。
2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA;
3.tomcat环境:Tomcat 7.x,8.x,9.x版本均可
4.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS;
5.是否Maven项目: 否;查看源码目录中是否包含pom.xml;若包含,则为maven项目,否则为非maven项目 

6.数据库:MySql 5.7/8.0等版本均可;

技术栈

后端:SSM(Spring+SpringMVC+Mybatis)

前端:HTML+CSS+Javascript+Layui

使用说明

1. 使用Navicat或者其它工具,在mysql中创建对应sql文件名称的数据库,并导入项目的sql文件;
2. 使用IDEA/Eclipse/MyEclipse导入项目,修改配置,运行项目;
3. 将项目中db.properties配置文件中的数据库配置改为自己的配置,然后运行;
4. 在浏览器中输入http://localhost:8080/LibraryProject/login
管理员用户名密码:admin/12345

读者用户名密码:zhangsan/12345

运行截图

读者

管理员

 

代码

相关代码 

BookInfoController

  1. package com.yx.controller;
  2. import com.github.pagehelper.PageInfo;
  3. import com.yx.po.BookInfo;
  4. import com.yx.po.TypeInfo;
  5. import com.yx.service.BookInfoService;
  6. import com.yx.service.TypeInfoService;
  7. import com.yx.utils.DataInfo;
  8. import org.springframework.beans.factory.annotation.Autowired;
  9. import org.springframework.stereotype.Controller;
  10. import org.springframework.ui.Model;
  11. import org.springframework.web.bind.annotation.*;
  12. import java.util.Arrays;
  13. import java.util.List;
  14. @Controller
  15. public class BookInfoController {
  16. @Autowired
  17. private BookInfoService bookInfoService;
  18. @Autowired
  19. private TypeInfoService typeInfoService;
  20. /**
  21. * 图书管理首页
  22. * @return
  23. */
  24. @GetMapping("/bookIndex")
  25. public String bookIndex(){
  26. return "book/bookIndex";
  27. }
  28. /**
  29. * 获取book信息,封装成json
  30. * @param bookInfo
  31. * @param pageNum
  32. * @param limit
  33. * @return
  34. */
  35. @RequestMapping("/bookAll")
  36. @ResponseBody //@ResponseBody将java对象转为json格式的数据,表示该方法的返回结果直接写入 HTTP response body 中,一般在异步ajax获取数据时使用
  37. public DataInfo bookAll(BookInfo bookInfo, @RequestParam(defaultValue = "1") Integer pageNum, @RequestParam(defaultValue = "15") Integer limit){
  38. PageInfo<BookInfo> pageInfo = bookInfoService.queryBookInfoAll(bookInfo,pageNum,limit);
  39. return DataInfo.ok("成功",pageInfo.getTotal(),pageInfo.getList());//总条数getTotal,数据封装成list,以便加载分页显示,由于加了ResponseBody,就会返回一个字符串
  40. }
  41. /**
  42. * 添加页面的跳转
  43. */
  44. @GetMapping("/bookAdd")
  45. public String bookAdd(){
  46. return "book/bookAdd";
  47. }
  48. /**
  49. * 类型添加提交
  50. */
  51. @RequestMapping("/addBookSubmit")
  52. @ResponseBody
  53. public DataInfo addBookSubmit(BookInfo info){
  54. bookInfoService.addBookSubmit(info);
  55. return DataInfo.ok();
  56. }
  57. /**
  58. * 类型根据id查询(修改)
  59. */
  60. @GetMapping("/queryBookInfoById")
  61. public String queryTypeInfoById(Integer id, Model model){
  62. BookInfo bookInfo= bookInfoService.queryBookInfoById(id);
  63. model.addAttribute("info",bookInfo);
  64. return "book/updateBook";
  65. }
  66. /**
  67. * 修改提交功能
  68. */
  69. @RequestMapping("/updateBookSubmit")
  70. @ResponseBody
  71. public DataInfo updateBookSubmit(@RequestBody BookInfo info){
  72. bookInfoService.updateBookSubmit(info);
  73. return DataInfo.ok();
  74. }
  75. /**
  76. * 类型删除
  77. */
  78. @RequestMapping("/deleteBook")
  79. @ResponseBody
  80. public DataInfo deleteBook(String ids){
  81. List<String> list= Arrays.asList(ids.split(","));
  82. bookInfoService.deleteBookByIds(list);
  83. return DataInfo.ok();
  84. }
  85. @RequestMapping("/findAllList")
  86. @ResponseBody
  87. public List<TypeInfo> findAll(){
  88. PageInfo<TypeInfo> pageInfo = typeInfoService.queryTypeInfoAll(null,1,100);
  89. List<TypeInfo> lists = pageInfo.getList();
  90. return lists;
  91. }
  92. }

LendListController

  1. package com.yx.controller;
  2. import com.github.pagehelper.PageInfo;
  3. import com.yx.po.BookInfo;
  4. import com.yx.po.LendList;
  5. import com.yx.po.ReaderInfo;
  6. import com.yx.service.BookInfoService;
  7. import com.yx.service.LendListService;
  8. import com.yx.service.ReaderInfoService;
  9. import com.yx.utils.DataInfo;
  10. import org.springframework.beans.factory.annotation.Autowired;
  11. import org.springframework.stereotype.Controller;
  12. import org.springframework.ui.Model;
  13. import org.springframework.web.bind.annotation.GetMapping;
  14. import org.springframework.web.bind.annotation.RequestMapping;
  15. import org.springframework.web.bind.annotation.RequestParam;
  16. import org.springframework.web.bind.annotation.ResponseBody;
  17. import javax.servlet.http.HttpServletRequest;
  18. import java.util.Arrays;
  19. import java.util.Date;
  20. import java.util.List;
  21. @Controller
  22. public class LendListController {
  23. @Autowired
  24. private LendListService lendListService;
  25. @Autowired
  26. private ReaderInfoService readerService;
  27. @Autowired
  28. private BookInfoService bookInfoService;
  29. @GetMapping("/lendListIndex")
  30. public String lendListIndex(){
  31. return "lend/lendListIndex";
  32. }
  33. /**
  34. * 查询所有的列表
  35. * 1 request获取
  36. * 2、参数绑定
  37. * 3、对象绑定
  38. */
  39. @ResponseBody
  40. @RequestMapping("/lendListAll")
  41. public DataInfo lendListAll(Integer type, String readerNumber, String name, Integer status,
  42. @RequestParam(defaultValue = "1")Integer page,@RequestParam(defaultValue = "15")Integer limit){
  43. LendList info=new LendList();
  44. info.setBackType(type);
  45. //创建读者对象
  46. ReaderInfo reader=new ReaderInfo();
  47. reader.setReaderNumber(readerNumber);
  48. //把以上对象交给info
  49. info.setReaderInfo(reader);
  50. //图书对象
  51. BookInfo book=new BookInfo();
  52. book.setName(name);
  53. book.setStatus(status);
  54. info.setBookInfo(book);
  55. //分页查询所有的记录信息
  56. PageInfo pageInfo=lendListService.queryLendListAll(info,page,limit);
  57. return DataInfo.ok("ok",pageInfo.getTotal(),pageInfo.getList());
  58. }
  59. /**
  60. * 添加跳转
  61. */
  62. @GetMapping("/addLendList")
  63. public String addLendList(){
  64. return "lend/addLendList";
  65. }
  66. /**
  67. * 借书信息提交
  68. * 1判断借阅号码是否存在
  69. * 2、可借的数据是否大于等于当前的借书量
  70. * 3、添加借书记录,同时改变书的状态信息
  71. * cardnumber:借书号码
  72. * ids:字符串 书id的集合
  73. */
  74. @ResponseBody
  75. @RequestMapping("/addLend")
  76. public DataInfo addLend(String readerNumber,String ids){
  77. //获取图书id的集合
  78. List<String> list= Arrays.asList(ids.split(","));
  79. //判断卡号是否存在
  80. ReaderInfo reader=new ReaderInfo();
  81. reader.setReaderNumber(readerNumber);
  82. PageInfo<ReaderInfo> pageInfo=readerService.queryAllReaderInfo(reader,1,1);
  83. if(pageInfo.getList().size()==0){
  84. return DataInfo.fail("卡号信息不存在");
  85. }else{
  86. ReaderInfo readerCard2=pageInfo.getList().get(0);
  87. //可借书
  88. for(String bid:list) {
  89. LendList lendList = new LendList();
  90. lendList.setReaderId(readerCard2.getId());//读者id
  91. lendList.setBookId(Integer.valueOf(bid));//书的id
  92. lendList.setLendDate(new Date());
  93. lendListService.addLendListSubmit(lendList);
  94. //更变书的状态
  95. BookInfo info = bookInfoService.queryBookInfoById(Integer.valueOf(bid));
  96. //设置书的状态
  97. info.setStatus(1);
  98. bookInfoService.updateBookSubmit(info);
  99. }
  100. }
  101. return DataInfo.ok();
  102. }
  103. /**
  104. * 删除借阅记录
  105. */
  106. @ResponseBody
  107. @RequestMapping("/deleteLendListByIds")
  108. public DataInfo deleteLendListByIds(String ids, String bookIds){
  109. List list=Arrays.asList(ids.split(","));//借阅记录的id
  110. List blist=Arrays.asList(bookIds.split(","));//图书信息的id
  111. lendListService.deleteLendListById(list,blist);
  112. return DataInfo.ok();
  113. }
  114. /**
  115. * 还书功能
  116. */
  117. @ResponseBody
  118. @RequestMapping("/backLendListByIds")
  119. public DataInfo backLendListByIds(String ids,String bookIds){
  120. List list=Arrays.asList(ids.split(","));//借阅记录的id
  121. List blist=Arrays.asList(bookIds.split(","));//图书信息的id
  122. lendListService.updateLendListSubmit(list,blist);
  123. return DataInfo.ok();
  124. }
  125. /**
  126. * 页面跳转 异常还书
  127. */
  128. @GetMapping("/excBackBook")
  129. public String excBackBook(HttpServletRequest request, Model model){
  130. //获取借阅记录id
  131. String id=request.getParameter("id");
  132. String bId=request.getParameter("bookId");
  133. model.addAttribute("id",id);
  134. model.addAttribute("bid",bId);
  135. return "lend/excBackBook";
  136. }
  137. /**
  138. * 异常还书
  139. */
  140. @ResponseBody
  141. @RequestMapping("/updateLendInfoSubmit")
  142. public DataInfo updateLendInfoSubmit(LendList lendList){
  143. lendListService.backBook(lendList);
  144. return DataInfo.ok();
  145. }
  146. /**
  147. * 查阅时间线
  148. */
  149. @RequestMapping("/queryLookBookList")
  150. public String queryLookBookList(String flag,Integer id,Model model){
  151. List<LendList> list=null;
  152. if(flag.equals("book")){
  153. list=lendListService.queryLookBookList(null,id);
  154. }else{
  155. list=lendListService.queryLookBookList(id,null);
  156. }
  157. model.addAttribute("info",list);
  158. return "lend/lookBookList";
  159. }
  160. @RequestMapping("/queryLookBookList2")
  161. public String queryLookBookList(HttpServletRequest request,Model model){
  162. ReaderInfo readerInfo = (ReaderInfo) request.getSession().getAttribute("user");
  163. List<LendList> list = list=lendListService.queryLookBookList(readerInfo.getId(),null);
  164. model.addAttribute("info",list);
  165. return "lend/lookBookList";
  166. }
  167. }

如果也想学习本系统,下面领取。关注并回复:273ssm 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/代码探险家/article/detail/750588
推荐阅读
相关标签
  

闽ICP备14008679号