博主主页:Java旅途
简介:分享计算机知识、学习路线、系统源码及教程
文末获取源码
一、项目介绍
图书管理系统基于SpringBoot+Mybatis开发,系统分为两种角色,分别是管理员和普通用户。
管理员功能如下:
- 书籍类别管理
- 新书录入
- 新书查询
- 用户管理
- 借阅记录
普通用户功能如下:
- 查询图书
- 借书
- 还书
- 借书记录
二、技术框架
- 后端:SpringBoot,Mybatis
- 前端:layui
三、安装教程
- 用idea打开项目
- 在idea中配置jdk环境
- 配置maven环境并下载依赖
- 新建数据库,导入数据库文件
- 在application.yml文件中将数据库账号密码改成自己本地的
- 启动运行,理员账号密码 admin/123456 ,普通用户账号密码 user/123456
四、项目截图
五、相关代码
BookController
package com.zbw.controller;
import com.zbw.domain.Book;
import com.zbw.domain.BookCategory;
import com.zbw.domain.Vo.BookVo;
import com.zbw.service.IAdminService;
import com.zbw.service.IBookCategoryService;
import com.zbw.service.IBookService;
import com.zbw.utils.page.Page;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
import java.util.List;
@Controller
public class BookController {
@Resource
private IAdminService adminService;
@Resource
private IBookService bookService;
@Resource
private IBookCategoryService bookCategoryService;
/**
* 管理员  录入新书
*
* @param book
* @return
*/
@RequestMapping("/addBook")
@ResponseBody
public String addBook(Book book) {
boolean res = adminService.addBook(book);
if (res) {
return "true";
}
return "false";
}
/**
* 返回  查询书籍结果页
*
* @param pageNum
* @param model
* @return
*/
@RequestMapping("/showBooksResultPageByCategoryId")
public String showBooksResultPageByCategoryId(@RequestParam("pageNum") int pageNum, @RequestParam("bookCategory") int bookCategory, Model model) {
Page<BookVo> page = bookService.findBooksByCategoryId(bookCategory, pageNum);
model.addAttribute("page", page);
model.addAttribute("bookCategory", bookCategory);
return "admin/showBooks";
}
/**
* 返回用户  查询书籍结果页
*
* @param bookPartInfo
* @return
*/
@RequestMapping("/findBookByBookPartInfo")
public String findBooksResultPage(@RequestParam("bookPartInfo") String bookPartInfo, Model model) {
List<BookVo> bookVos = bookService.selectBooksByBookPartInfo(bookPartInfo);
model.addAttribute("bookList", bookVos);
return "user/findBook";
}
/**
* 查询所有书籍种类
*
* @return
*/
@RequestMapping("/findAllBookCategory")
@ResponseBody
public List<BookCategory> findAllBookCategory() {
return adminService.getBookCategories();
}
/**
* 新建书籍种类
*
* @param bookCategory
* @return
*/
@RequestMapping("/addBookCategory")
@ResponseBody
public String addBookCategory(BookCategory bookCategory) {
boolean b = adminService.addBookCategory(bookCategory);
if (b) {
return "true";
}
return "false";
}
/**
* 根据书籍种类id删除种类
*
* @param bookCategoryId
* @return
*/
@RequestMapping("/deleteCategory")
@ResponseBody
public String deleteBookCategoryById(@RequestParam("bookCategoryId") int bookCategoryId) {
int res = bookCategoryService.deleteBookCategoryById(bookCategoryId);
if (res > 0) {
return "true";
}
return "false";
}
}
BorrowingController
package com.zbw.controller;
import com.zbw.domain.Vo.BorrowingBooksVo;
import com.zbw.service.IBorrowingBooksRecordService;
import com.zbw.utils.page.Page;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import javax.annotation.Resource;
@Controller
public class BorrowingController {
@Resource
private IBorrowingBooksRecordService borrowingBooksRecordService;
/**
* 返回所有用户借书记录页面
*
* @return
*/
@RequestMapping("/allBorrowBooksRecordPage")
public String allBorrowingBooksRecordPage(Model model, @RequestParam("pageNum") int pageNum) {
Page<BorrowingBooksVo> page = borrowingBooksRecordService.selectAllByPage(pageNum);
model.addAttribute("page", page);
return "admin/allBorrowingBooksRecord";
}
}
大家点赞、收藏、关注、评论啦 、👇🏻点开下方卡片👇🏻关注后回复 100