1. 1 objective 4
1.2 range 4
1.3 Definitions in this system 4
2 data reference 4
3 Design concept 4
3. 1 data layer design 5
Trigger 5 of user_book table
The storage process of renewing books by users 6
Due Repayment View Table 7
3.2 Data Link Layer Design 8
User Manual Entity Bean Design 9
User Consumer Entity Bean Design 10
User log entity Bean design 1 1
3.3 Data Logic Layer Design 12
Book conversation Bean design 13
User session Bean design 14
Log session Bean design 15
3.4 Network Application Layer Design 15
Check value bean 16
Coding bean 16
JDBCBean bean 16
Ranked beans 16
Install bean 16
SplitPage bean 17
User login bean 17
Search book bean 17
SearchDeadline bean 17
Verify servlet 17
get delete servlet servlet 17
GetBookSubmit servlet 18
GetUserSubmit servlet 18
GetRenewBook servlet 18
GetBorrowBook servlet 18
GetReturnBook servlet 18
4 program architecture 18
4. 1 project organization structure 18
4.2 Division of functions and authorities 20
4.3 Web Program/Page Design 2 1
4.4 Functions Implemented by the System 22
5 Division of tasks 22
1 preface
1. 1 purpose
This document describes the design of the book management system in detail, mainly to let developers have a deep understanding of the construction and maintenance of this project.
1.2 range
The description in this document only applies to the 1.0 version of the library management system.
1.3 Definitions in this system
The following are the definitions of technical terms used in this manual and the original phrases of foreign initial words:
Definitions and descriptions of terms or abbreviations
The name of the system.
Reader system permissions: ordinary readers
BookAdmin system permissions: librarian
User Administrator System Privileges: User Administrator
SuperAdmin System Privilege: Super Administrator (System Administrator)
User role of undergraduate system: undergraduate
User role of postgraduate system: postgraduate
Teacher system user role: teacher
2 data reference
Tsinghua University application software platform and core technology lecture notes Gu Ming.
Tsinghua University application software platform and core technology teaching assistant documents: Zhang, Chen Yong, Lin.
Master EJB (second edition)
J2EE application and BEA Web logical server. Trans. Xing Guoqing and others. Electronic Industry Press, April 2002.
Design pattern-the basis of reusable object-oriented software, Erich Gamma et al., Machinery Industry Press.
3 design concept
The system is designed in strict accordance with the four-layer structure, which is divided into data layer (SQL server), data link layer (entity bean), data logic layer (session bean) and network application layer (Java Bean, Java Servlet, Java Server Page).
The four layers are completely independent and can be deployed on four servers, which embodies the idea of distributed application.
Strictly speaking, the function of data layer is to realize basic data storage (all logical processing functions should be handed over to CMP management), but for learning reasons, some logical processing is also used in the database, such as using stored procedures+system-level temporary tables to deal with readers' renewed books, using triggers to prevent users who have not returned books and books from being cancelled, and using views to detect book borrowing records to realize expiration reminders.
The data link layer realizes the connection with the database, and its function is to shield the difference between the database and the platform and realize the bottom independence. This layer uses fuzzy search, multi-table mapping, relationship and other technologies, and throws aggregate objects or remote interface objects to the next layer through the search function of find find and select method data.
The data logic layer realizes the logical processing of data, such as converting remote interface objects into value objects, converting aggregate objects into value object vectors, and using date classes to complete relatively complex calculations, such as finding records between two specific dates.
The network application layer completes application functions such as page jumping and page display, and some additional functions such as picture verification, login verification, grade control, code filtering, paging control, input value detection, book borrowing log printing, system running log recording, system setting, etc. (JDBC is used to implement stored procedures and fuzzy book search functions)
3. 1 data layer design
Database table
Table name function description
User_consumer records all the information of users.
User_book records all the information of the book.
User_logBook records the information of users using this system, and keeps all the book borrowing records, which can be used as system logs and report materials.
Trigger of user_book table
If the book to be cancelled is lent out and not returned, one of the triggers used to roll back the deletion operation.
Create a trigger bookhavelog on dbo.user_book.
Used to delete
be like
declare @bookISBN varchar(50)
select @ book ISBN = book _ ISBN from deleted
If there is (select * from user_logBook where logb_book_ISBN=@bookISBN and
Logb_backdate is empty)
begin
reverse
return
end
The storage process of users renewing books
Stored procedures are used to realize the logical operation of renewing books for users. According to the user's current information, judge whether he has the right to renew books, and output the processing result to the temporary table.
Create process user_renew_book @xxxparm int AS
Create table ##temp (statement varchar(50))
DECLARE @username varchar(50)
SET @username= (select logb_cons_username from user_logBook, where ID=@xxxparm).
If the @ user name is empty
begin
Insert into # # temporary value ('ID does not exist')
return
end
Declare @timelimit int
Set @ timelimit = (select logb _ timelimit from user _ logbook, where ID=@xxxparm).
Declare @renewday int
SET @ renew day =(select cons _ maxday from user _ consumer where cons _ username = @ username)
Declare @ maxrenewaint
SET @ max renew =(select cons _ max renew from user _ consumer where cons _ username = @ username)
IF(@ renew day * @ max renew)& gt; =@timelimit
begin
Update user _ logbook set logb _ timelimit = logb _ timelimit+@ renewday where ID=@xxxparm.
-updateuser _ consumerset cons _ maxupdates = cons _ maxupdates-1where cons_username=@username.
Inserting # # temporary values ('Renewal succeeded')
return
end
other
begin
Insert into # # temporary value ('You are not allowed to renew the book')
return
end
go to
View of due reminder table
Use DATEDIFF, DATEADD, CAST, GETDATE and other functions to calculate the expiration record from the book borrowing record table, and then find out the corresponding reader information according to this record, and return it by email on the webpage.
Create view dbo.deadline
be like
SELECT TOP 100 PERCENT dbo . user _ logbook . logb _ cons _ username,
Dbo.user_logBook.logb_outdate, DATEADD([ day], dbo.user _ logbook.logb _ time limit,
CAST(dbo . user _ logbook . logb _ outdate AS datetime))AS deadline _ date,GETDATE()
Such as now_date, dbo.user_consumer.cons_name, dbo.user_consumer.cons_kind,
dbo.user_consumer.cons_rank,dbo.user_consumer.cons_email,
dbo . user _ consumer . cons _ max renew,dbo.user_consumer.cons_maxbook,
dbo . user _ logbook . logb _ book _ ISBN,dbo.user_book.book_name,
dbo.user_book.book_kind,dbo.user_book.book_storage,dbo.user_book.book_rank,
dbo . user _ logbook . logb _ time limit
FROM dbo.user_logBook internal connection
dbo.user_consumer ON
dbo . user _ logbook . logb _ cons _ username = dbo . user _ cons . cons _ username INNER
join
dbo.user_book ON
dbo . user _ logbook . logb _ book _ ISBN = dbo . user _ book . book _ ISBN
Where (DATEDIFF([ day], DATEADD([ day], dbo.user _ logbook.logb _ time limit,
CAST(dbo . user _ logbook . logb _ outdate AS datetime))、GETDATE())& gt; = 0) and
(dbo.user_logBook.logb_backdate is empty)
Orders are based on dbo.user _ logbook.logb _ cons _ usernamedesc.
3.2 Data Link Layer Design
Entity bean
User manual entity Bean design
User Manual Remote Home Interface
Method description
FindAllBook to get all the book information.
FindByISBN obtains the information of books through their book numbers.
FindSearcher uses the fuzziness of keywords to find book information.
selectUserByBookISBN
(userbook remote) uses select method to realize multi-table association search.
Code for fuzzy search:
Select the object (p) from the user manual as p, where p.bookName is similar to concat(concat('%',? 1),'%') or do you like it? 1 or p.bookKind like? 1 or p. book release like it? 1 or p. book abstract like it? 1 or p.bookISBN like concat(concat('%',? 1),'%') or p.bookRemark like? 1
User consumer entity Bean design
User-consumer remote homepage interface
Method description
Find all user information.
FindByUsername looks up user information by user name.
FindSearcher uses keyword ambiguity to find user information.
Select book by user name.
(userconsumer remote) uses the select method to realize multi-table association search.
Code for fuzzy search:
select object(p from user consumer as p where p . consusername like concat(concat(' % ',? 1),'%') or p.consSerial like? 1 or p.consName like concat(concat('%',? 1),'%') or p.consRemark like? 1 or p.consEmail or something? 1
Design of user log entity Bean
User Log Remote Home Interface
Method description
FindallbybookISBN searches all the borrowing records of this book.
FindbybookISBN looks up the current borrowing record of this book.
Findallbyusername to find all the borrowing records of this user.
Findbyusername to find the current borrowing record of this user.
Findbacklog gets the borrowing records of all returned books.
Findoutlog gets the borrowing records of all the books that have not been returned.
FindbyID finds the book borrowing record by recording the serial number.
Findlogbyday looks up the book borrowing records of a certain date.
(Fuzzy matching, such as submitting "May 2004" to get the final record time-borrowing or returning all borrowing records in May 2004)
Findallog gets all the book borrowing records.
FindLogByDay gets a set of codes that finally record the time through fuzzy matching:
Select the object (p) from the user log as p, where (p.logbBackdate is null and p.logbOutdate is concat(concat('%',? 1),'%') or (p.logbBackdate is not null and p.logbBackdate is similar to concat(concat('%',? 1),'%') )
3.3 Data Logic Layer Design
Session bean
Design of book conversation Bean
Shudou
Realize the functions of adding, deleting, changing and searching books, fuzzy searching, searching readers through books and so on.
Method implements all logical processing and conversion internally, and returns to the remote interface value object or value object vector.
User session Bean design
User bean
Users (readers) can add, delete, change, search, search books and other functions through the reader.
Method implements all logical processing and conversion internally, and returns to the remote interface value object or value object vector.
Log session Bean design
carob
It mainly realizes various operations on the log (book borrowing record) and provides various ways to obtain the log (by reader, by book, by date, by borrowing and returning status, etc.). ). All logical processing and transformation are realized inside the method, which returns to the remote interface value object or value object vector. In addition, there are the following methods:
Method function
The public boolean userborrowbook (string username, String Book ISBN) encapsulates all the logical operations of readers borrowing books with one transaction. When borrowing a book successfully returns a true value, it cannot return a false value, so we call enCode bean to transcode Chinese.
The Public Boolean user Returnbook (String Logbid) encapsulates all the logical operations of returning books for a transaction, that is, it realizes the function of writing off the borrowing records of books, and calls enCode bean to transcode Chinese.
The public vector show log between days (string day begin, String Day End) returns all the logs between two dates, which is mainly realized by the Calendar class.
3.4 Network Application Layer Design
This layer is designed according to the principles of encapsulation, data fuzziness and reusability of object-oriented thought.
According to the error handling principle of system operation error printing in the system (System.out.println), user input and misoperation errors lead to friendly error handling pages and give friendly prompts.
Every call to the session bean is written to the system running log file, and the default path is c: \ \ booksmanagerlog.dat.
Check value bean
Encapsulates multiple static methods.
It can be used to detect whether a value already exists in a field of a table (it can be used to detect duplicate users and duplicate books), and to detect the legitimacy of user name, password, age, email, numbers, date, etc.
Coded bean
Packaging, coding and transcoding:
Html shows code conversion, for example, conversion
Chinese transcoding that can be overloaded.
Encryption and decryption coding of passwords.
JDBCBean bean
Encapsulates all database operations. Including SQL execution methods with result set return and SQL execution methods without result set return.
Grade bean
Encapsulating page access with four permissions (ordinary reader, user administrator, librarian and system administrator) is equivalent to page locking function.
Install bean
public static String title = " super library "; //System name
Common static string dbS = "booksManagerDS///JNDI name of the database.
Common static string errorpage = "deallerror.jsp? theError = "; //Friendly error handling page, with the get method to pass the error reason.
public static String home page = " default . JSP "; //Default Home Page
//authority-.
Public static string Reader = "Reader// reader
Public static string UserAdmin = "UserAdmin// user administrator.
Public static string BookAdmin = "BookAdmin// librarian.
Public static string SuperAdmin = "SuperAdmin// System Administrator
//grade-.
Public static string undergraduate = "undergraduate"; //undergraduates
public static int undergater enew = 1; //The number of times undergraduates can renew their loans.
public static int undebudatemaxday = 30; //The number of days that undergraduates can borrow at a time.
Public static string Graduate = "Graduate// graduate student.
public static int graduate new = 2; //The number of times graduate students can renew their loans.
public static int graduate max day = 45; //The number of days graduate students can borrow at a time.
Public static string Teacher = "Teacher// teacher.
public static int teacher new = 3; //The number of times the teacher can renew it.
public static int teacher max day = 60; //The number of days the teacher can borrow at a time.
// -
public static int rsPerPage = 5; //Displays the number of records per page.
public static int min books = 4; //The system default minimum borrowing quantity.
SplitPage bean
The logical realization of data record paging and page display (the simplest, which can be beautified with style sheets) is encapsulated in a bean. When reusing, only a few parameters of a recordset need to be passed, which is reusable. Generally, it is called as a session-level java bean in a page, and the user's access status to the page is saved in the session, and the page number corresponding to the user's access to the page is always remembered before the session ends.
User login bean
The logical realization of user login and page display (the simplest, which can be beautified with style sheets) is encapsulated in a bean, including the handling of various login situations of users, which can be reused.
Search for book beans
Using JDBC to realize fuzzy retrieval and accurate retrieval of books.
SearchDeadline bean
Using JDBC call view to realize the function of returning expired books.
Verify servlet
Dynamically generate a picture with a random verification code, write the verification code into the session while generating the picture, and compare it with the user's login input. It can effectively prevent robots from logging in.
GetDelete servlet servlet
Handle the logout operation of books, users and logs, and jump to the corresponding page according to the return value.
GetBookSubmit servlet
Handle the storage of books and the modification of book information, and jump to the corresponding page according to the return value.
GetUserSubmit servlet
Handle user registration and user information modification, and jump to the corresponding page according to the return value.
GetRenewBook servlet
Handle the user's renewal request (JDBC calls stored procedures), read the status value from the temporary table of the system, and jump to the corresponding page according to the status value.
GetBorrowBook servlet
Handle the user's request for borrowing books, and guide the errors such as the user's borrowing limit is full and the inventory is zero to the friendly error page. If the book is borrowed successfully, jump to the book information page and give the corresponding prompt.
GetReturnBook servlet
Handle the user's book return request. If the book is returned successfully, jump to the user's book borrowing record page and give the corresponding prompt.
4 program architecture
4. 1 project organization structure
Description: As the external functions of the system, book search and user login directly call the database through JDBC, in which the user login module is encapsulated in a java bean and can be reused. In addition, users renew books through stored procedures, thus bypassing entity bean that use CMP technology to manage transactions.
The organizational structure of other projects in this system is strictly in accordance with the following figure:
Plan organization chart
4.2 Division of functions and authorities
Website page map
The rights name system defines the rights of a role to access a page.
Ordinary readers read their own information (returning books, renewing books);
Modify your own information;
Look up books (borrow books); User modification
User view
book list
Librarian BookAdmin has the authority of ordinary readers;
Add, delete and check books;
Repayment due; User modification
User view
book list
bookkeeper
Book revision
deadline
User administrator UserAdmin has the rights of ordinary readers;
Add, delete and query users; User modification
User view
book list
user registration
User modification
User list
SuperAdmin, system administrator, has the authority of librarian and user administrator;
View the system log;
Delete the system log;
System settings; All pages including setupSYS.jsp (system settings, using application-level java bean to control the whole application).
4.3 Web Program/Page Design
use
Use onfocus = this. select () onmouseover = this。 The focus () code makes the text box automatically absorb and get the focus, which is convenient for users to input.
Use WMODE="transparent "parameter to make the background of flash transparent and better integrate into the web page.
On each page, use the code:
& ltIFRAME frame border = 0 height = 88 margin height = 0 margin width = 0 scrolling = no src = "../iframe/top . htm " width = 755 border color = " # 000000 " >& lt/IFRAME & gt;
& ltIFRAME frame border = 0 height = 68 margin height = 0 margin width = 0 scrolling = no src = "../iframe/below . htm " width = 755 border color = " # 000000 " >& lt/IFRAME & gt;
Embedded up and down navigation bars make the website navigation clear and convenient for users to browse.
Add code to the header:
& ltmeta HTTP-EQUIV = " pragma " CONTENT = " no-cache " & gt;
& ltmeta HTTP-EQUIV = " expires " CONTENT = " 0 " >
The client does not cache the web page, which ensures that the client obtains the latest version from the server every time it browses the page, thus displaying it correctly.
Provide intelligent search (get as many matches as possible) and accurate search (get as accurate matches as possible) books, and the server-side programming adopts fuzzy search method.
Use javascript on the client to check the form submission for the first time, and then submit it to the server for the second time. The check code includes: whether the user name is duplicate, whether the age is an appropriate number, whether the two passwords are consistent, whether the email address is legal, whether the password is too short, whether the user name is too short, whether the user name password is empty, and so on.
Using the method of randomly generating JPG picture verification code to prevent robots from logging in.
Use session-level java bean to achieve paging in the page, save the user's access status to the page in the session, and always remember the page number corresponding to the user's access to the page before the end of the session.
Use application-level java bean to achieve secure system settings in the page. When the server is started, the system running parameters can be set at the application level. As long as the server is not shut down, this setting is always valid and applies to all users. If careless settings cause system errors or you want to restore the system default settings, you just need to restart the server.
In the call package ejbClient of the session bean, create a system running log, and write it into C:\\booksManagerLog.dat of the web server through the writeF class in the package, which can be used for query.
4.4 Functions realized by this system
Determine the basic information of the book, including the title, author, publication date, current borrowing status and other attributes.
The users of the system include readers, librarians, user administrators and system administrators.
Readers can consult books; Librarians can complete book management and borrowing management; The reader administrator can complete the function of reader management; System administrators can use all the functions of the system.
Book management: new book registration, book inquiry and book cancellation;
Borrowing management: borrowing and returning books, and inquiring overdue readers.
Reader management: increase readers, delete readers, query readers, and manage reader categories (set the number of books that can be borrowed by graduate students, undergraduates, teachers, etc., the number of days that can be borrowed, the number of times that can be renewed, etc. )
System management: used by system administrators, including user rights management (adding users, deleting users, modifying passwords, etc. ), system borrowing log, system running log, system settings and other functions.
The page is entered with a verification code, and the password access is encrypted.
Scheduled expiration reminder
Reflect the hierarchical design idea and use MVC architecture.
A number of beans are realized, and the corresponding relationship between beans is realized.
EJB QL, transaction control and so on are all used.
Use JSP-& gt;; session bean-& gt; entity bean-& gt; Database schema
The database uses some advanced technologies, such as triggers and stored procedures.