赞
踩
作者主页:夜未央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
- package com.yx.controller;
-
- import com.github.pagehelper.PageInfo;
- import com.yx.po.BookInfo;
- import com.yx.po.TypeInfo;
- import com.yx.service.BookInfoService;
- import com.yx.service.TypeInfoService;
- import com.yx.utils.DataInfo;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Controller;
- import org.springframework.ui.Model;
- import org.springframework.web.bind.annotation.*;
-
- import java.util.Arrays;
- import java.util.List;
-
- @Controller
- public class BookInfoController {
-
- @Autowired
- private BookInfoService bookInfoService;
-
- @Autowired
- private TypeInfoService typeInfoService;
-
- /**
- * 图书管理首页
- * @return
- */
- @GetMapping("/bookIndex")
- public String bookIndex(){
- return "book/bookIndex";
- }
-
- /**
- * 获取book信息,封装成json
- * @param bookInfo
- * @param pageNum
- * @param limit
- * @return
- */
- @RequestMapping("/bookAll")
- @ResponseBody //@ResponseBody将java对象转为json格式的数据,表示该方法的返回结果直接写入 HTTP response body 中,一般在异步ajax获取数据时使用
- public DataInfo bookAll(BookInfo bookInfo, @RequestParam(defaultValue = "1") Integer pageNum, @RequestParam(defaultValue = "15") Integer limit){
- PageInfo<BookInfo> pageInfo = bookInfoService.queryBookInfoAll(bookInfo,pageNum,limit);
- return DataInfo.ok("成功",pageInfo.getTotal(),pageInfo.getList());//总条数getTotal,数据封装成list,以便加载分页显示,由于加了ResponseBody,就会返回一个字符串
- }
-
- /**
- * 添加页面的跳转
- */
- @GetMapping("/bookAdd")
- public String bookAdd(){
- return "book/bookAdd";
- }
-
- /**
- * 类型添加提交
- */
- @RequestMapping("/addBookSubmit")
- @ResponseBody
- public DataInfo addBookSubmit(BookInfo info){
- bookInfoService.addBookSubmit(info);
- return DataInfo.ok();
- }
-
- /**
- * 类型根据id查询(修改)
- */
- @GetMapping("/queryBookInfoById")
- public String queryTypeInfoById(Integer id, Model model){
- BookInfo bookInfo= bookInfoService.queryBookInfoById(id);
- model.addAttribute("info",bookInfo);
- return "book/updateBook";
- }
-
- /**
- * 修改提交功能
- */
-
- @RequestMapping("/updateBookSubmit")
- @ResponseBody
- public DataInfo updateBookSubmit(@RequestBody BookInfo info){
- bookInfoService.updateBookSubmit(info);
- return DataInfo.ok();
- }
- /**
- * 类型删除
- */
-
- @RequestMapping("/deleteBook")
- @ResponseBody
- public DataInfo deleteBook(String ids){
- List<String> list= Arrays.asList(ids.split(","));
- bookInfoService.deleteBookByIds(list);
- return DataInfo.ok();
- }
-
- @RequestMapping("/findAllList")
- @ResponseBody
- public List<TypeInfo> findAll(){
- PageInfo<TypeInfo> pageInfo = typeInfoService.queryTypeInfoAll(null,1,100);
- List<TypeInfo> lists = pageInfo.getList();
- return lists;
- }
- }

LendListController
- package com.yx.controller;
-
- import com.github.pagehelper.PageInfo;
- import com.yx.po.BookInfo;
- import com.yx.po.LendList;
- import com.yx.po.ReaderInfo;
- import com.yx.service.BookInfoService;
- import com.yx.service.LendListService;
- import com.yx.service.ReaderInfoService;
- import com.yx.utils.DataInfo;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Controller;
- import org.springframework.ui.Model;
- import org.springframework.web.bind.annotation.GetMapping;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.RequestParam;
- import org.springframework.web.bind.annotation.ResponseBody;
-
- import javax.servlet.http.HttpServletRequest;
- import java.util.Arrays;
- import java.util.Date;
- import java.util.List;
-
- @Controller
- public class LendListController {
- @Autowired
- private LendListService lendListService;
- @Autowired
- private ReaderInfoService readerService;
-
- @Autowired
- private BookInfoService bookInfoService;
-
- @GetMapping("/lendListIndex")
- public String lendListIndex(){
- return "lend/lendListIndex";
- }
-
- /**
- * 查询所有的列表
- * 1 request获取
- * 2、参数绑定
- * 3、对象绑定
- */
- @ResponseBody
- @RequestMapping("/lendListAll")
- public DataInfo lendListAll(Integer type, String readerNumber, String name, Integer status,
- @RequestParam(defaultValue = "1")Integer page,@RequestParam(defaultValue = "15")Integer limit){
-
- LendList info=new LendList();
- info.setBackType(type);
-
- //创建读者对象
- ReaderInfo reader=new ReaderInfo();
- reader.setReaderNumber(readerNumber);
- //把以上对象交给info
- info.setReaderInfo(reader);
-
- //图书对象
- BookInfo book=new BookInfo();
- book.setName(name);
- book.setStatus(status);
- info.setBookInfo(book);
-
- //分页查询所有的记录信息
- PageInfo pageInfo=lendListService.queryLendListAll(info,page,limit);
- return DataInfo.ok("ok",pageInfo.getTotal(),pageInfo.getList());
- }
-
-
- /**
- * 添加跳转
- */
- @GetMapping("/addLendList")
- public String addLendList(){
- return "lend/addLendList";
- }
-
- /**
- * 借书信息提交
- * 1判断借阅号码是否存在
- * 2、可借的数据是否大于等于当前的借书量
- * 3、添加借书记录,同时改变书的状态信息
- * cardnumber:借书号码
- * ids:字符串 书id的集合
- */
- @ResponseBody
- @RequestMapping("/addLend")
- public DataInfo addLend(String readerNumber,String ids){
- //获取图书id的集合
- List<String> list= Arrays.asList(ids.split(","));
- //判断卡号是否存在
- ReaderInfo reader=new ReaderInfo();
- reader.setReaderNumber(readerNumber);
- PageInfo<ReaderInfo> pageInfo=readerService.queryAllReaderInfo(reader,1,1);
- if(pageInfo.getList().size()==0){
- return DataInfo.fail("卡号信息不存在");
- }else{
- ReaderInfo readerCard2=pageInfo.getList().get(0);
- //可借书
- for(String bid:list) {
- LendList lendList = new LendList();
- lendList.setReaderId(readerCard2.getId());//读者id
- lendList.setBookId(Integer.valueOf(bid));//书的id
- lendList.setLendDate(new Date());
- lendListService.addLendListSubmit(lendList);
- //更变书的状态
- BookInfo info = bookInfoService.queryBookInfoById(Integer.valueOf(bid));
- //设置书的状态
- info.setStatus(1);
- bookInfoService.updateBookSubmit(info);
- }
-
- }
-
- return DataInfo.ok();
- }
-
-
- /**
- * 删除借阅记录
- */
- @ResponseBody
- @RequestMapping("/deleteLendListByIds")
- public DataInfo deleteLendListByIds(String ids, String bookIds){
- List list=Arrays.asList(ids.split(","));//借阅记录的id
- List blist=Arrays.asList(bookIds.split(","));//图书信息的id
-
- lendListService.deleteLendListById(list,blist);
- return DataInfo.ok();
- }
-
- /**
- * 还书功能
- */
- @ResponseBody
- @RequestMapping("/backLendListByIds")
- public DataInfo backLendListByIds(String ids,String bookIds){
- List list=Arrays.asList(ids.split(","));//借阅记录的id
- List blist=Arrays.asList(bookIds.split(","));//图书信息的id
- lendListService.updateLendListSubmit(list,blist);
- return DataInfo.ok();
- }
-
- /**
- * 页面跳转 异常还书
- */
- @GetMapping("/excBackBook")
- public String excBackBook(HttpServletRequest request, Model model){
- //获取借阅记录id
- String id=request.getParameter("id");
- String bId=request.getParameter("bookId");
- model.addAttribute("id",id);
- model.addAttribute("bid",bId);
- return "lend/excBackBook";
- }
-
- /**
- * 异常还书
- */
- @ResponseBody
- @RequestMapping("/updateLendInfoSubmit")
- public DataInfo updateLendInfoSubmit(LendList lendList){
- lendListService.backBook(lendList);
- return DataInfo.ok();
- }
-
- /**
- * 查阅时间线
- */
- @RequestMapping("/queryLookBookList")
- public String queryLookBookList(String flag,Integer id,Model model){
- List<LendList> list=null;
- if(flag.equals("book")){
- list=lendListService.queryLookBookList(null,id);
- }else{
- list=lendListService.queryLookBookList(id,null);
- }
- model.addAttribute("info",list);
- return "lend/lookBookList";
- }
-
- @RequestMapping("/queryLookBookList2")
- public String queryLookBookList(HttpServletRequest request,Model model){
- ReaderInfo readerInfo = (ReaderInfo) request.getSession().getAttribute("user");
- List<LendList> list = list=lendListService.queryLookBookList(readerInfo.getId(),null);
- model.addAttribute("info",list);
- return "lend/lookBookList";
- }
-
-
- }

如果也想学习本系统,下面领取。关注并回复:273ssm
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。