本文主要是介绍图书租赁系统-借阅图书,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
图中展示了所有可以借阅的图书,点击“借阅”按钮便可以借阅图书。
借阅成功后,可以到bookorder菜单中阅读该书。
阅读功能待开发。
add.html借阅图书页面
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head><th:block th:include="include :: header('新增bookorder')" /><th:block th:include="include :: datetimepicker-css" />
</head>
<body class="white-bg"><div class="wrapper wrapper-content animated fadeInRight ibox-content"><form class="form-horizontal m" id="form-order-add"><div class="form-group"> <label class="col-sm-3 control-label">book_id:</label><div class="col-sm-8"><input name="bookId" class="form-control" type="text" th:value="${bookId}"></div></div><div class="form-group"> <label class="col-sm-3 control-label">借阅结束时间:</label><div class="col-sm-8"><div class="input-group date"><input name="endTime" class="form-control" placeholder="yyyy-MM-dd HH:mm:ss" type="text"><span class="input-group-addon"><i class="fa fa-calendar"></i></span></div></div></div></form></div><th:block th:include="include :: footer" /><th:block th:include="include :: datetimepicker-js" /><script th:inline="javascript">var prefix = ctx + "system/order"$("#form-order-add").validate({focusCleanup: true});function submitHandler() {if ($.validate.form()) {$.operate.save(prefix + "/add", $('#form-order-add').serialize());}}$("input[name='startTime']").datetimepicker({format: "yyyy-mm-dd",minView: "month",autoclose: true});$("input[name='endTime']").datetimepicker({format: "yyyy-mm-dd hh:ii",autoclose: true});</script>
</body>
</html>
book.html图书列表
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head><th:block th:include="include :: header('book列表')" />
</head>
<body class="gray-bg"><div class="container-div"><div class="row"><div class="col-sm-12 search-collapse"><form id="formId"><div class="select-list"><ul><li><label>书名:</label><input type="text" name="bookName"/></li><li><a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i> 搜索</a><a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i> 重置</a></li></ul></div></form></div><div class="btn-group-sm" id="toolbar" role="group"><a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="system:book:add"><i class="fa fa-plus"></i> 添加</a><a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="system:book:edit"><i class="fa fa-edit"></i> 修改</a><a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="system:book:remove"><i class="fa fa-remove"></i> 删除</a><a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="system:book:export"><i class="fa fa-download"></i> 导出</a></div><div class="col-sm-12 select-table table-striped"><table id="bootstrap-table"></table></div></div></div><th:block th:include="include :: footer" /><script th:inline="javascript">var editFlag = [[${@permission.hasPermi('system:book:edit')}]];var removeFlag = [[${@permission.hasPermi('system:book:remove')}]];var prefix = ctx + "system/book";$(function() {var options = {url: prefix + "/list",createUrl: prefix + "/add",updateUrl: prefix + "/edit/{id}",removeUrl: prefix + "/remove",exportUrl: prefix + "/export",modalName: "book",columns: [{checkbox: true},{field: 'bookId',title: '图书编号',visible: false},{field: 'bookName',title: '书名'},{title: '操作',align: 'center',formatter: function(value, row, index) {var actions = [];actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" οnclick="borrowBook(\'' + row.bookId + '\')"><i class="fa fa-edit"></i>租借</a> ');actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" οnclick="$.operate.remove(\'' + row.bookId + '\')"><i class="fa fa-remove"></i>xxx</a>');return actions.join('');}}]};$.table.init(options);});function borrowBook(bookid){$.modal.open("借阅" , "http://localhost/system/order/add?bookId="+bookid);}</script>
</body>
</html>
book.java图书实体类
package com.ruoyi.system.domain;import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;/*** book对象 book* * @author ruoyi* @date 2024-04-23*/
public class Book extends BaseEntity
{private static final long serialVersionUID = 1L;/** 图书编号 */private Long bookId;/** 书名 */@Excel(name = "书名")private String bookName;public void setBookId(Long bookId) {this.bookId = bookId;}public Long getBookId() {return bookId;}public void setBookName(String bookName) {this.bookName = bookName;}public String getBookName() {return bookName;}@Overridepublic String toString() {return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE).append("bookId", getBookId()).append("bookName", getBookName()).toString();}
}
请求“http://localhost/system/order/add”对应的方法
/*** 新增bookorder*/@GetMapping("/add")public String add(String bookId, ModelMap mmap){System.out.println("bookId = " + bookId);mmap.put("bookId",bookId);return prefix + "/add";}
BookController.java
package com.ruoyi.web.controller.system;import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.Book;
import com.ruoyi.system.service.IBookService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;/*** bookController* * @author ruoyi* @date 2024-04-23*/
@Controller
@RequestMapping("/system/book")
public class BookController extends BaseController
{private String prefix = "system/book";@Autowiredprivate IBookService bookService;@RequiresPermissions("system:book:view")@GetMapping()public String book(){return prefix + "/book";}/*** 查询book列表*/@RequiresPermissions("system:book:list")@PostMapping("/list")@ResponseBodypublic TableDataInfo list(Book book){startPage();List<Book> list = bookService.selectBookList(book);return getDataTable(list);}/*** 导出book列表*/@RequiresPermissions("system:book:export")@Log(title = "book", businessType = BusinessType.EXPORT)@PostMapping("/export")@ResponseBodypublic AjaxResult export(Book book){List<Book> list = bookService.selectBookList(book);ExcelUtil<Book> util = new ExcelUtil<Book>(Book.class);return util.exportExcel(list, "book数据");}/*** 新增book*/@GetMapping("/add")public String add(){return prefix + "/add";}/*** 新增保存book*/@RequiresPermissions("system:book:add")@Log(title = "book", businessType = BusinessType.INSERT)@PostMapping("/add")@ResponseBodypublic AjaxResult addSave(Book book){return toAjax(bookService.insertBook(book));}/*** 修改book*/@RequiresPermissions("system:book:edit")@GetMapping("/edit/{bookId}")public String edit(@PathVariable("bookId") Long bookId, ModelMap mmap){Book book = bookService.selectBookByBookId(bookId);mmap.put("book", book);return prefix + "/edit";}/*** 修改保存book*/@RequiresPermissions("system:book:edit")@Log(title = "book", businessType = BusinessType.UPDATE)@PostMapping("/edit")@ResponseBodypublic AjaxResult editSave(Book book){return toAjax(bookService.updateBook(book));}/*** 删除book*/@RequiresPermissions("system:book:remove")@Log(title = "book", businessType = BusinessType.DELETE)@PostMapping( "/remove")@ResponseBodypublic AjaxResult remove(String ids){return toAjax(bookService.deleteBookByBookIds(ids));}
}
BookMapper.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.system.mapper.BookMapper"><resultMap type="Book" id="BookResult"><result property="bookId" column="book_id" /><result property="bookName" column="book_name" /></resultMap><sql id="selectBookVo">select book_id, book_name from book</sql><select id="selectBookList" parameterType="Book" resultMap="BookResult"><include refid="selectBookVo"/><where> <if test="bookName != null and bookName != ''"> and book_name like concat('%', #{bookName}, '%')</if></where></select><select id="selectBookByBookId" parameterType="Long" resultMap="BookResult"><include refid="selectBookVo"/>where book_id = #{bookId}</select><insert id="insertBook" parameterType="Book" useGeneratedKeys="true" keyProperty="bookId">insert into book<trim prefix="(" suffix=")" suffixOverrides=","><if test="bookName != null">book_name,</if></trim><trim prefix="values (" suffix=")" suffixOverrides=","><if test="bookName != null">#{bookName},</if></trim></insert><update id="updateBook" parameterType="Book">update book<trim prefix="SET" suffixOverrides=","><if test="bookName != null">book_name = #{bookName},</if></trim>where book_id = #{bookId}</update><delete id="deleteBookByBookId" parameterType="Long">delete from book where book_id = #{bookId}</delete><delete id="deleteBookByBookIds" parameterType="String">delete from book where book_id in <foreach item="bookId" collection="array" open="(" separator="," close=")">#{bookId}</foreach></delete></mapper>
编程过程中遇到的问题:
我想将下面的内容复制到上面去,但是idea会自动把单斜杠变成双斜杠。此时就可以用记事本打开book.html,然后再复制即可。
这篇关于图书租赁系统-借阅图书的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!