100字范文,内容丰富有趣,生活中的好帮手!
100字范文 > Java项目:图书借阅管理系统(java+JSP+bootstrap+jQuery+Servlet+Mysql)

Java项目:图书借阅管理系统(java+JSP+bootstrap+jQuery+Servlet+Mysql)

时间:2021-05-30 13:59:41

相关推荐

Java项目:图书借阅管理系统(java+JSP+bootstrap+jQuery+Servlet+Mysql)

项目介绍

本项目分为读者、管理员两种角色,登录验证码。

管理员主要功能包括:

图书管理:1)根据图书名称、作者、分类查询图书基本信息

2)添加、修改或删除图书信息

读者管理:1)根据账号、姓名、ID查询读者基本信息

2)添加、修改或删除读者信息

图书分类管理:1)查看图书分类信息,显示分类ID

2)添加、修改或删除图书分类

图书借阅信息:1)展示所有正在借阅的图书信息与读者信息

2)可以实现还书与延期功能

图书归还信息:1)展示所有已归还的图书的信息

2)记录图书出馆时间与归馆时间

管理员管理(需登录):1)仅最高管理员可以访问本页面

2)添加、修改或删除管理员信息

热门推荐:1)展示每一本书的借阅量,包括图书基本信息

2)可以查询书籍借阅量

最佳读者:展示每一位已知读者的借阅量,以及读者的基本信息

读者登录主要功能包括:

图书查询、借阅信息、借阅历史、热门推荐、最佳读者、问题反馈;

环境需要

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.数据库:MySql 5.7版本;

6.是否Maven项目: 否;查看源码目录中是否包含pom.xml;若包含,则为maven项目,否则为非maven项目

技术栈

1. 后端:Servlet

2. 前端:JSP+bootstrap+jQuery

使用说明

1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件;

2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;

若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行;

3. 将项目中util/DBUtil.java配置文件中的数据库配置改为自己的配置;

4. 运行项目,输入http://localhost:8080/books/login.jsp 登录 注:tomcat中配置项目路径必须为/books

管理员用户名密码:101/101.123456

读者用户名密码:1816270150/wyz123456

用户图书管理控制层:

/*** @description: 前台页面列表显示处理*/@Controller@RequestMapping("/user/ch")public class UserBookController {// 注入@Autowiredprivate LibraryService libraryService;@Autowiredprivate LibraryCategoryService libraryCategoryService;@Autowiredprivate CommentService commentService;@Autowiredprivate TbOrderMapper orderMapper;@Autowiredprivate TbRecordMapper recordMapper;@Value("${LOGIN_USER}")private String LOGIN_USER; // 当前登录用户的 session 存储 属性名@RequestMapping("/user_bookList")public String toLibraryListByCid(TbLibraryQuery libraryQuery, PageCount pageCount, Model model, HttpSession session) {if (libraryQuery == null || libraryQuery.getCateId() == null) {libraryQuery = new TbLibraryQuery();libraryQuery.setCateId((Integer) session.getAttribute("currentCategory"));}// 根据 类目 id// 若 当前 类目 为 父类目 则获取 其 下面 的 所有子类目// 若 当前 类目 为 子类目 则获取 其 同级 类目List<TbCategory> categoryList = libraryCategoryService.getCategoryByCid(libraryQuery.getCateId());// 获取当前类目信息TbCategory currentCategory = libraryCategoryService.getCategoryById(libraryQuery.getCateId());// 按照条件进行查询PageCount<TblibraryExt> libraryPageCount = libraryService.findLibraryByAll(libraryQuery, pageCount);// model 将数据设置到域中model.addAttribute("subCategoryList", categoryList);model.addAttribute("libraryPageCount", libraryPageCount);// 默认if (currentCategory == null) {currentCategory = new TbCategory();currentCategory.setId(0);}session.setAttribute("currentCategory", currentCategory.getId());return "/user/user_bookList";}/*** 通过 图书 id 查询 图书详细信息** @param id* @return*/@RequestMapping("/bookId")public String toBookInfo(int id, Model model) {BookExt bookInfo = libraryService.getBookInfoById(id);// 将 时间戳 进行转换Long dateSS = bookInfo.getLibrary().getCreatedate();SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");String formatDate = simpleDateFormat.format(new Date(dateSS * 1000));bookInfo.setFormatDate(formatDate);// 通过 图书id 获取 回复信息List<CommentExt> commentExts = commentService.findCommentByBookId(id);// 将 查询的 图书信息 设置到 域 中model.addAttribute("bookInfo", bookInfo);// 将 回复信息 设置到 域 汇总model.addAttribute("commentExts", commentExts);return "/user/bookDetail";}/*** 用于 借阅 图书 操作** @param session 用于 取 用户信息* @param order 用户借阅关联信息* @return*/@RequestMapping("/jieyue_book")public String jieyueBook(HttpSession session, Model model, String oid, String kkid, TbOrder order) {if (null != kkid) {TbRecord tbRecord = recordMapper.selectByPrimaryKey(Integer.valueOf(kkid));tbRecord.setReturnbook(2); //2代表挂失recordMapper.updateByPrimaryKey(tbRecord);model.addAttribute("successMsg", "图书挂失成功");return "errorMsg";}if (null != oid) {TbRecord tbOrder = recordMapper.selectByPrimaryKey(Integer.valueOf(oid));// 插入数据tbOrder.setBackdate(tbOrder.getBackdate() + 3 * 30 * 24 * 60 * 60);recordMapper.updateByPrimaryKey(tbOrder);model.addAttribute("successMsg", "续借三个月成功");return "errorMsg";}// 获取 session 中的用户信息ActiveUser activeUser = (ActiveUser) session.getAttribute("activeUser");TbUser tbUser = new TbUser();tbUser.setId(activeUser.getUserid());order.setUserId(tbUser.getId());// 插入数据libraryService.jieyueBookById(order);return "redirect:/user/ch/bookId.action?id=" + order.getBookId();}@RequestMapping("/commitInfo")@ResponseBodypublic String commitComment(HttpSession session, TbComment comment) {// 获取 session 中的用户信息ActiveUser activeUser = (ActiveUser) session.getAttribute("activeUser");TbUser tbUser = new TbUser();tbUser.setId(activeUser.getUserid());comment.setUserId(tbUser.getId());libraryService.addCommentInfo(comment);return "ok";}}</pre>

登录注册管理控制层:

/*** @desc 登录注册Controller**/@Controller@RequestMapping("/login")public class Login_LoginController {@Autowiredprivate Login_loginValidation login_loginValidation;@RequestMapping("/login")public String login(Model model, HttpSession session, String user, String pwd, String passwd2, String tel, String authcode, String statu) throws Exception {//提示信息String msg;//跳转页面String url;//登录ActiveUser activeUser = new ActiveUser();TbUser tbUser = new TbUser();if ("1".equals(statu)) {activeUser = this.login_loginValidation.authenticat(user, pwd);if (activeUser == null) {msg = "用户名或密码错误!";url = "/login.action";model.addAttribute("msg", msg);model.addAttribute("url", url);return "user/error";}session.setAttribute("activeUser", activeUser);return "redirect:/user/userSystem.action";} else if ("2".equals(statu)) { //注册//获取生成的验证码String validateCode = (String) session.getAttribute("randomCode");//判断用户名或密码是否为空if ("".equals(user) || user == null || "".equals(pwd) || pwd == null) {msg = "用户名或密码不能为空!";url = "/login.action";model.addAttribute("msg", msg);model.addAttribute("url", url);}//判断两次密码是否不一致if (!pwd.equals(passwd2)) {msg = "您输入的两次密码不一致!";url = "/login.action";model.addAttribute("msg", msg);model.addAttribute("url", url);}//判断手机号是否为空if (!"".equals(tel) || tel == null) {msg = "手机号不能为空!";url = "/login.action";model.addAttribute("msg", msg);model.addAttribute("url", url);}//判断验证码是否错误if (!validateCode.equals(authcode)) {msg = "您输入的验证码错误!";url = "/login.action";model.addAttribute("msg", msg);model.addAttribute("url", url);return "user/error";}//如果都正确,注册用户tbUser.setUsername(user);tbUser.setPassword(pwd);tbUser.setTelnum(tel);long nowTime = System.currentTimeMillis() / 1000;tbUser.setRegisterdate(nowTime);int result = this.login_loginValidation.addUser(tbUser);//判断是否注册成功if (0 == result) {msg = "注册失败,用户名已存在!";url = "/login.action";model.addAttribute("msg", msg);model.addAttribute("url", url);return "user/error";}//注册成功,将用户名放入seesion中tbUser = this.login_loginValidation.findUserByUserName(user);activeUser.setUserid(tbUser.getId());activeUser.setUsername(tbUser.getUsername());activeUser.setHeadImg(tbUser.getHeadimg());session.setAttribute("activeUser", activeUser);msg = "注册成功!正在为您登录,请稍候...";url = "/user/userSystem.action";model.addAttribute("msg", msg);model.addAttribute("url", url);return "user/error";} else {msg = "参数错误!";url = "/login.action";model.addAttribute("msg", msg);model.addAttribute("url", url);return "user/error";}}//账号退出登录@RequestMapping("/logout")public String logout(HttpSession session) throws Exception {session.invalidate();return "redirect:/login.action";}// 管理员登录@RequestMapping("/adminlogin")public String adminlogin(Model model, HttpSession session, String adminuser, String adminpassword) throws Exception {String msg;String url;//判断用户名为空if ("".equals(adminuser) || adminuser == null || "".equals(adminpassword) || adminpassword == null) {msg = "用户名或密码不能为空!";url = "/admin.action";model.addAttribute("msg", msg);model.addAttribute("url", url);return "user/error";}ActiveAdmin activeAdmin = this.login_loginValidation.authenticatAdmin(adminuser, adminpassword);if (activeAdmin == null) {msg = "用户名或密码错误!";url = "/admin.action";model.addAttribute("msg", msg);model.addAttribute("url", url);return "user/error";}session.setAttribute("activeAdmin", activeAdmin);return "redirect:/admin/admin.action";}}</pre>

图书类别管理控制层:

/*** @description: 图书类别处理*/@Controller@RequestMapping("/admin/ch/category")public class CategoryController {//注入@Autowiredprivate LibraryCategoryService libraryCategoryService;/*** 添加 图书类目** @param category 图书类目信息* @param session 添加人* @return url* @author hiseico*/@RequestMapping(value = "/addCategory", method = RequestMethod.POST)public String addCategory(TbCategory category, HttpSession session, Model model) {List<TbCategory> categoryList = libraryCategoryService.getCategoryAll();boolean is = false;for (TbCategory tbCategory : categoryList) {if (category.getCatname().equals(tbCategory.getCatname())) {is = true;break;}}if (!is) {// 添加 数据到 数据库,并 修改 父类目libraryCategoryService.addBookCategory(category, session);} else {model.addAttribute("errorMsg", "类目已经存在");return "errorMsg";}return "redirect:/admin/ch/loan_BookClassify.action";}/*** 删除类目信息** @param id* @return*/@RequestMapping(value = "/delCategory", method = RequestMethod.GET)public String delCategory(int id) {// 通过 类目id 删除数据libraryCategoryService.delBookCategoryById(id);return "redirect:/admin/ch/loan_BookClassify.action";}/*** 修改 类目关系** @param category* @return*/@RequestMapping(value = "/updateCategory", method = RequestMethod.POST)public String updateCategory(TbCategory category) {return "redirect:/admin/ch/loan_BookClassify.action";}@RequestMapping("/toUpdatePage")@ResponseBodypublic TbCategory toUpdatePage(int id) {return libraryCategoryService.getCategoryById(id);}}</pre>

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。