Project Description
Build a simple online mall system through Spring Boot. The main functions include: user registration, user login, adding products, browsing products, product details page, personal homepage, balance recharge, purchasing products, viewing orders, etc. This article mainly introduces the business process and project architecture. To save space, the complete code will not be explained in detail. The complete project can be downloaded in GitHub, link: Online Mall System
Software and Development Environment
- Operating system: Windows 10
- Development software: IntelliJ IDEA 2021.2.3, Navicat Premium 15.0.23
- Programming language: JDK 1.8, MySQL 8.0.27
- Browser: Firefox 98.0.2
Business Process
- Business Core: Inventory Processing
After the user purchases the product, the inventory and user balance are reduced, and finally the purchase record is recorded. The three components form a complete transaction to avoid overselling and underselling.
- Business Difficulties: Competition
Solved by using transactions and row-level locks. Transaction process: Open transaction->Update inventory->Update balance->Insert purchase record->Submit.
Application Technology
- Project management: Maven
- Development languages: Java, MySQL, HTML, CSS, JavaScript
- Framework: Spring Boot, Mybatis, jQuery
- Design patterns: singleton pattern, wrapper pattern
Project Development
- DAO: Implement DOMapper and DAO interfaces through mybatis-generator.
- MVC: Avoid transparent transmission of sensitive information (passwords, balances, etc.) to the front end through conversion between model and viewobject. The product price is stored in BigDecimal to avoid loss of accuracy.
- Web: Interact with the front-end through the Restful interface, and the front-end uses ajax to receive data. Avoid cross domain issues by @CrossOrigin and setting xhrFields in ajax.
- Service: Manage services through Spring and conduct transaction control through Spring's declarative transactions.
- Exception: Set the error code and error information through enum, and catch the exception in BaseController.java.
- User login: Verify mobile phone number and password. After successful login, IS_LOGIN and LOGIN_USER are stored in the session.
- Mall interface: display products, click on a single product to enter the product details page, and obtain individual product information through GET.
- Order placement: Determine whether the user is logged in (IS_LOGIN), verify (inventory, balance, etc.), reduce product inventory and user balance, and add purchase records.
Project screenshots
login interface
Adding goods
check order
registered user
Mall main interface
Product details page
User Center