博主主页:Java旅途
简介:分享计算机知识、学习路线、系统源码及教程
文末获取源码
图书管理系统基于SpringBoot+Mybatis开发,系统分为两种角色,分别是管理员和普通用户。
管理员功能如下:
普通用户功能如下:
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