Xhotel
Introduction
TopView Studio's first round of assessment project: Hotel Management System (Huang Yuchao)
xhotel is a hotel management system that provides backend technologies such as viewing rooms, booking rooms, personal information management, room and hotel information management (administrators) and other functions: Java, tomcat, mysql, servlet, jsp
Quick Start
Click here to experience it now
Information
Developer: Huang Yuchao Contact Email: [email protected]
Project development time: 2019-04-04 to 2019-04-25
Version number: 1.0.0
Open Source License: Apache License 2.0
Running environment:
- tomcat 9.0.17
- mysql 5.7.29
- jdk 1.8
Features
1. Login page

2. Home page
3. Fuzzy query room

4. Message board

Functions implemented
1. User module
- Registration function
- Login function
- Remember the login status and log in automatically next time
- Log out
- Users view personal information and modify their own personal information
- Users upload their own avatar and modify their own avatar
- Users modify their login password
- Users modify their payment password
- Search for rooms, view room information, book room
- You can choose check-in time and departure time in the order
- You can fill in the remarks information in the order
- Users view their own orders and cancel their own orders
- You can leave a message on the message board to view other people's comments
2. Administrator module
- Administrators can add new users
- Administrators can add new rooms
- The administrator can modify the room information and delete the room
3. Super Administrator
- Add, delete, check and modify the hotel (no interface display, only completed to the Dao level)
Code Features
Security
- Use regular input checks and do not allow illegal data to enter the database
- PrepareStatement prevents sql injection
- Filter label injection
- Encrypt user password using md5
- Use uuid to ensure global uniqueness
- Null pointer check
Code reusability
- All Dao is a subclass of BaseDao. The subclass is only responsible for processing data passed in corresponding Service layer and writing some SQL statements. All database operations are in the two methods of BaseDao.
- The po layer uses an inheritance system. All entities inherit (directly or indirectly) BaseEntity, storing the id, status, gmt_create, and gmt_modified information of the database table, and both rooms and services inherit the Product class, and both rooms and service orders inherit the Order.
- md5 encryption, obtaining uuid, and other functions are put into tool class to reuse
- Repeat code extraction and reconstruction, optimize code using template methods and policy patterns, etc.
Maintainability
- Code comments: Most of the code provides class comments, method comments, and attribute comments
- Interface documentation: Use javadoc annotations to provide API documentation
- Interface-oriented programming: both the Dao layer and the Service layer provide upward interfaces, separate from the implementation class
- Encapsulation: Po, vo layer only has getter and setter methods
- Robustness: Most classes have corresponding test classes and have undergone multiple rounds of testing
- Standardization: Unify the front-end request parameter specifications, and use enumeration classes to manage request parameters
- Use configuration files, database configuration, connection pool configuration, and factory configuration are all separated from the code
- MVC design pattern: There is no page output in the servlet, no Java code in JSP, and data processing is all placed into the service layer
- Almost no "magic value": most constants use enumeration classes, very few use final variables, and the rest are constants in the front-end partial request parameters
- Avoid code contamination: encapsulate CheckException into RuntimeException and throw it to the upper layer to avoid coupling between layers
- Single Responsibilities: Each Service has its own corresponding Dao layer implementation class, and each Service and Dao can complete its own functions separately.
Encapsulation of data entry and exit:
- Front-end data: All request parameters are mapped into entity class objects through BeanUtils, and in this process, the label injection is uniformly filtered.
- Persistent data: All database update operations and database query operations are encapsulated in BaseDaoImpl's executeUpdate and executeQuery methods. Only these two methods can connect to the database connection pool, and resources can be obtained and released uniformly.
- Query result set data: BaseDaoImpl encapsulates all database update operations and most query operations. Only a few queries are executed through subclasses and SQL statements. The processing of the result set is all encapsulated by BaseDaoImpl
- Status and processing results: All the turntable codes and processed data returned by the service layer are returned in the Result
- Page data: All data returned to the front end are returned in PageVo
performance
- Handwritten database connection pool to improve database access performance
Design Pattern
- Factory model
- Singleton mode
- Policy Mode
- Decorative mode
- Template method
- MVC mode
Project development log:
Updated April 20: Build basic jsp pages
Updated April 17: Building rooms, orders and other services
Updated on April 14: Build the control layer, UserService implementation
Updated on April 12: Build rooms, orders are implemented
Updated April 11: Build UserDao
Updated on April 10: Building the basic layer
Updated on April 9: Preliminary construction of Dao layer
Updated April 8: Build a database connection pool
Updated April 7: Build a project
Updated on April 3: Submit project requirements analysis (project naming: Xhotel)
Updated on April 1: Currently in the stage of demand analysis, establishing data models and preliminary design of business processes
Updated on March 30: The project of CAT Studio has just been completed, and the QG bootcamp has a task, so I haven't started yet
Be prepared to summarize the experience of the CAT project first, and understand some problems you encounter before writing the project.
License
This software is for communication and learning only and may not be used for commercial purposes
Copyright Huang Yuchao
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.