This is the 17th day of my participation in the August Challenge
Subscribe to download the source code
preface
With the development of network technology, computer application level widely improved, the original system of timeliness, data correctness, convenient operation are insufficient, has affected the normal use of the system. After investigation and comparison, I decided to redesign the library management system, so that the system can use the results of software development technology to facilitate the management of books. Library management system is a typical information management system. The system introduces the development process of the book system, the problems encountered in the design and the solutions to improve the current application or system development progress and improve the work performance. The use of its various object-oriented development tools to establish a system application prototype in a short period of time and then the initial prototype system for demand iteration, continuous modification and improvement, until the formation of user satisfaction with the feasible system. This course design uses JAVA development tools and Mysql database to develop the library management system. The system to solve the library management to solve the problem, can meet the basic requirements of the library management, including adding, management and other functions. The system can quickly and conveniently provide readers with borrowing services according to the needs of users.
Background significance
With the wide application of computer, it has gradually become a symbol of modernization. The library or some internal enterprises, even the bookstore, in the normal operation process is always faced with a large number of reader information, book information and the interaction of the two generated book borrowing information, book information. Therefore need to readers, books, resources, borrow books information, return books information management, timely understanding of change in the information in the various sectors, to timely processing of the resulting documents, in order to improve the library, or enterprise internal management of the books in automation, can more quickly to meet the requirements of the readers, improve the efficiency of all kinds of work, Now the corresponding system is designed. The main function of the library management system is to realize the automation of library books borrowing and returning management. Around this main function, the system involves the following core functions: borrowing management, return management. In addition to these core functions, also includes some basic and auxiliary functions, they are: user management, library management, book query.
Database design
The users table
CREATE TABLE `NewTable` (
`admin_id` int(11) NOT NULL AUTO_INCREMENT ,
`admin_name` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ,
`admin_pwd` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ,
`admin_email` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ,
PRIMARY KEY (`admin_id`)
)
ENGINE=InnoDB
DEFAULT CHARACTER SET=utf8 COLLATE=utf8_general_ci
AUTO_INCREMENT=2
ROW_FORMAT=DYNAMIC
;
Copy the code
The book table
CREATE TABLE `NewTable` (
`book_id` int(11) NOT NULL AUTO_INCREMENT ,
`book_name` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ,
`book_author` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ,
`book_publish` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ,
`book_category` int(11) NULL DEFAULT NULL ,
`book_price` double NULL DEFAULT NULL ,
`book_introduction` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ,
PRIMARY KEY (`book_id`),
FOREIGN KEY (`book_category`) REFERENCES `book_category` (`category_id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
INDEX `book_category` (`book_category`) USING BTREE
)
ENGINE=InnoDB
DEFAULT CHARACTER SET=utf8 COLLATE=utf8_general_ci
AUTO_INCREMENT=72
ROW_FORMAT=DYNAMIC
;
Copy the code
Book type
CREATE TABLE `NewTable` (
`category_id` int(11) NOT NULL AUTO_INCREMENT ,
`category_name` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ,
PRIMARY KEY (`category_id`)
)
ENGINE=InnoDB
DEFAULT CHARACTER SET=utf8 COLLATE=utf8_general_ci
AUTO_INCREMENT=51
ROW_FORMAT=DYNAMIC
;
Copy the code
library
CREATE TABLE `NewTable` (
`id` int(11) NOT NULL AUTO_INCREMENT ,
`user_id` int(11) NULL DEFAULT NULL ,
`book_id` int(11) NULL DEFAULT NULL ,
`date` date NULL DEFAULT NULL ,
PRIMARY KEY (`id`),
FOREIGN KEY (`book_id`) REFERENCES `book` (`book_id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
FOREIGN KEY (`user_id`) REFERENCES `user` (`user_id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
INDEX `user_id` (`user_id`) USING BTREE ,
INDEX `book_id` (`book_id`) USING BTREE
)
ENGINE=InnoDB
DEFAULT CHARACTER SET=utf8 COLLATE=utf8_general_ci
AUTO_INCREMENT=67
ROW_FORMAT=DYNAMIC
;
Copy the code
Screenshot function
Login:
A user selects a role and enters the account and password to log in
Home page:
The main modules after login are
Book management Input new books, Type Management, Query data
User Management Add User, Query User
Borrowing Management Borrowing Records
Personal information view and modify exit, etc
Book Management:
User management:
Lending Management:
Personal Information:
client
After logging in, users can view their lending records, as well as borrowing and returning books and other operations
Code implementation
The function of this project is relatively simple, and the technology we use is also very familiar with the technology, mainly springboot, SpringMVC, mybatis before jquery, Layui, HTML and CSS and other basic styles. Take the login as a complete example, starting with writing the front-end static page and sending the login request
<! DOCTYPE html> <html lang="zh-CN" xmlns:th="http://www.thymeleaf.org"> <head> <meta charset="UTF-8"> <title>Title</title> <link rel="stylesheet" th:href="@{/layui/css/layui.css}"> <style> body { /*width: 100%; */ /*height: 100%; */ background: url("/images/background.png") no-repeat; /*background: url("static/images/a.png") no-repeat; */ background-size: cover; } #login_form { width: 400px; height: 300px; margin: 80px auto; padding: 30px; background-color: #f2f2f2; Opacity: 0.9; } </style> </head> <body> <div id="wrapper" style="margin-top: 260px"> <div class="layui-container" id="login_form"> <div> <h1 style="color: red; text-align: Center "> Library </h1> <br> </div> <form class="layui-form" id="my_form" method="post" action="/userLogin"> <div Class ="layui-form-item"> <label class="layui-form-label"> user name :</label> <div class="layui-input-block"> <input type="text" Name ="userName" ID ="userName" autofocus placeholder=" please input userName" autocomplete="off" class="layui-input"> </div> </div> <div Class ="layui-form-item"> <label class="layui-form-label"> secret code :</label> <div class="layui-input-block"> <input Autocomplete ="off" class="layui-input"> </div> </div> <div class="layui-form-item"> <label class="layui-form-label"> User identity </label> <div class="layui-input-block"> <input Class ="form-check-input" type="radio" name="role" value="1" title=" student "checked> <input class="form-check-input" type="radio" name="role" value="1" title=" student" Type ="radio" name="role" value="0" title=" administrator "> </div> </div> <div class="layui-form-item layui-col-md4 <button id="sub_btn" class="layui-btn layui-btn-normal"> </button> </div> </div> <script th:src="@{/scripts/jquery.min.js}"></script> <script th:src="@{/layui/layui.js}"></script> <script th:inline="javascript"> layui.use(['layer', 'form'], function () { let layer = layui.layer; let form = layui.form; form.render(); $(function () { let flag = [[${session.flag}]]; If (flag) {layer. MSG (" username or password error ", {icon: 2, time: 2000 //2 seconds off (if not configured, default 3 seconds)}); }}); }); $("#sub_btn").click(function () { let username = $("#username").val(); let user_judge = check(username); If (user_judge) {let password = $("#password").val(); let pwd_judge = check(password); If (pwd_judge) {let role_id = $('input[name="role"]:checked').val(); / / if role_id = = 1, it is a regular user, submit the form directly if (role_id = = 1) {$(" # my_form "). The submit (); } else {/ / if the administrator, will be the action to change $(" # my_form "). Attr (" action ", "/ adminLogin") $(" # my_form "). The submit (); }} else {layer.alert(" password cannot be empty ", {icon: 5}); return false; }} else {layer.alert(" username cannot be empty ", {icon: 5}); return false; }}); // Verify whether username and password are entered in the form, if there is a value -> return true, if not return false; function check(val) { val = val.toString().trim(); return ! (val == ''); } </script> </body> </html>Copy the code
After receiving the login request from the front end, the background Controller performs parameter verification, verifies the user name, password and user role transferred from the front end, invokes the userservice. userLogin method to perform userLogin authentication, queries whether the current account and password of the database are correct, and returns the status code to the front end and the front end Status code for relative page jumps and data effects.
** @param userName * @return */ @postMapping ("/userLogin") public String userLogin(@param ("userName") String userName, @Param("password") String password, HttpServletRequest request) { User user = userService.userLogin(userName, password); if (null ! Request.getsession ().setattribute ("flag", 0); request.getSession().setAttribute("user", user); return "user/index"; Request.getsession ().setattribute ("flag", 1);} // If flag is 1, the login fails. return "index"; }Copy the code
Subscribe to download the source code
In general, this project is relatively simple and excellent, suitable for beginners as a reference for course design and graduation design