作者主页:夜未央5788
简介:Java领域优质创作者、Java项目、学习资料、技术互助
文末获取源码
项目介绍
本系统分为管理员与普通用户两种角色;
管理员角色包含以下功能:
借书管理,图书信息管理,图书分类管理,用户管理,角色管理,还书管理,登录页面等功能。
用户角色包含以下功能:
借阅管理,图书检索,查看借还记录,查看图书详情,还书管理,登录页面等功能。
环境需要
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项目:是;
技术栈
1. 后端:SpringBoot
2. 前端:JSP+CSS+JavaScript+bootstrap
使用说明
1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件;
2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;
若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行;
3. 将项目中application.properties配置文件中的数据库配置改为自己的配置;
4. 运行项目,在浏览器中输入localhost:18083/ 登录
运行截图
管理员角色
普通用户角色
代码相关
图书管理控制器
@RestController
@RequestMapping("/bookinfo")
public class BookInfoController {
@Resource
private BookInfoService bookInfoService;
@Resource
private BookTypeService bookTypeService;
@PostMapping("/save")
@LoginRequired
public JsonData saveBookInfo(BookInfo bookInfo) {
int count = bookInfoService.saveBookInfo(bookInfo);
if (count > 0) {
return JsonData.success(count, "新增成功");
} else {
return JsonData.fail("新增失败");
}
}
@PutMapping("/update")
@LoginRequired
public JsonData updateBookInfo(BookInfo bookInfo) {
int count = bookInfoService.updateBookInfo(bookInfo);
if (count > 0) {
return JsonData.success(count, "编辑成功");
} else {
return JsonData.fail("编辑失败");
}
}
@DeleteMapping("/delete")
@LoginRequired
public JsonData deleteBookInfo(Integer bookId) {
int count = bookInfoService.deleteBookInfo(bookId);
if (count > 0) {
return JsonData.success(count, "删除成功");
} else {
return JsonData.fail("删除失败");
}
}
@PostMapping("/list")
@LoginRequired
public DataGridDataSource<BookInfo> bookInfoList(@RequestParam(value = "bookIsbn", required = false, defaultValue = "") String bookIsbn,
@RequestParam(value = "bookName", required = false, defaultValue = "") String bookName,
@RequestParam(value = "bookAuthor", required = false, defaultValue = "") String bookAuthor,
@RequestParam(value = "page", required = false, defaultValue = "1") Integer page,
@RequestParam(value = "rows", required = false, defaultValue = "10") Integer rows) {
PageBean pageBean = new PageBean(page, rows);
Map<String, Object> map = new HashMap<>();
map.put("start", pageBean.getStart());
map.put("size", pageBean.getPageSize());
map.put("bookIsbn", "%" + bookIsbn + "%");
map.put("bookName", "%" + bookName + "%");
map.put("bookAuthor", "%" + bookAuthor + "%");
List<BookInfo> bookInfoList = bookInfoService.selectBookInfoList(map);
for (BookInfo bookInfo : bookInfoList) {
List<BookType> bookTypeList = bookTypeService.selectBookTypeListByBookTypeId(bookInfo.getBookType());
for (BookType bookType : bookTypeList) {
bookInfo.setTypes(bookType.getBookTypeName());
}
}
int totalBook = bookInfoService.getTotalBook(map);
DataGridDataSource<BookInfo> bookInfoDataGridDataSource = new DataGridDataSource<>();
bookInfoDataGridDataSource.setTotal(totalBook);
bookInfoDataGridDataSource.setRows(bookInfoList);
return bookInfoDataGridDataSource;
}
@GetMapping("/detail")
@LoginRequired
public JsonData bookInfoDetail(Integer bookId) {
List<BookInfo> bookInfos = bookInfoService.selectBookById(bookId);
for (BookInfo bookInfo : bookInfos) {
List<BookType> bookTypeList = bookTypeService.selectBookTypeListByBookTypeId(bookInfo.getBookType());
for (BookType bookType : bookTypeList) {
bookInfo.setTypes(bookType.getBookTypeName());
}
}
return JsonData.success(bookInfos);
}
@PostMapping("/info")
@LoginRequired
public JsonData bookInfo(Integer bookId) {
return JsonData.success(bookInfoService.selectBookInfoById(bookId));
}
}
图书类型管理控制器
@RestController
@RequestMapping("/booktype")
public class BookTypeController {
@Resource
private BookTypeService bookTypeService;
@PostMapping("/loadAllBookTypeData")
@LoginRequired
public Object loadAllBookTypeData() {
List<BookType> bookTypes = new ArrayList<>();
List<BookType> bookTypeList = bookTypeService.queryAllBookType();
Map<Integer, BookType> bookTypeMap = new HashMap<>();
for (BookType bookType : bookTypeList) {
bookTypeMap.put(bookType.getBookTypeId(), bookType);
}
for (BookType bookType : bookTypeList) {
BookType child = bookType;
if (child.getBookTypeParentId() == null) {
bookTypes.add(bookType);
} else {
BookType parent = bookTypeMap.get(child.getBookTypeParentId());
parent.getChildren().add(child);
}
}
return bookTypes;
}
@PostMapping("/listByBookTypeId")
@LoginRequired
public DataGridDataSource<BookType> selectBookTypeListByBookTypeId(@RequestParam(defaultValue = "0") Integer bookTypeId) {
List<BookType> bookTypeList = bookTypeService.selectBookTypeListByBookTypeId(bookTypeId);
DataGridDataSource<BookType> dataGridDataSource = new DataGridDataSource<>();
dataGridDataSource.setRows(bookTypeList);
dataGridDataSource.setTotal(bookTypeList.size());
return dataGridDataSource;
}
@DeleteMapping("/delete")
@LoginRequired
public JsonData deleteBookType(@RequestParam(value = "bookTypeId") Integer bookTypeId) {
int count = bookTypeService.deleteBookType(bookTypeId);
if (count > 0) {
return JsonData.success(count, "删除成功");
} else {
return JsonData.fail("删除失败");
}
}
@PostMapping("/save")
@LoginRequired
public JsonData saveBookType(BookType bookType) {
int count = bookTypeService.saveBookType(bookType);
if (count > 0) {
return JsonData.success(count, "新增成功");
} else {
return JsonData.fail("新增失败");
}
}
@PutMapping("/update")
@LoginRequired
public JsonData update(BookType bookType) {
int count = bookTypeService.updateBookType(bookType);
if (count > 0) {
return JsonData.success(count, "修改成功");
} else {
return JsonData.fail("修改失败");
}
}
}
如果也想学习本系统,下面领取。回复:061springboot