完善秒杀页面
This commit is contained in:
43
CLAUDE.md
43
CLAUDE.md
@@ -2,6 +2,15 @@
|
||||
|
||||
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
||||
|
||||
## 始终使用中文回复
|
||||
|
||||
- 在所有沟通和代码注释中,必须使用中文进行交流
|
||||
- 保持语言的专业性和技术准确性
|
||||
|
||||
## mcp 工具使用
|
||||
|
||||
- 当涉及到相关库的使用时,应该用 context7 查询相关文档
|
||||
|
||||
## Project Overview
|
||||
|
||||
FlashSaleSystem is a high-concurrency flash sale (秒杀) system built with Spring Boot and Redis Cluster. The system
|
||||
@@ -29,6 +38,19 @@ and Lua scripts.
|
||||
- **DTOs**: Data transfer objects for API communication
|
||||
- **Entities**: JPA entities mapping to database tables
|
||||
|
||||
### Package Structure
|
||||
|
||||
```
|
||||
com.org.flashsalesystem/
|
||||
├── controller/ # REST controllers and web endpoints
|
||||
├── service/ # Business logic and Redis operations
|
||||
├── repository/ # JPA repositories for data access
|
||||
├── entity/ # JPA entities (User, Product, Order, FlashSale)
|
||||
├── dto/ # Data transfer objects
|
||||
├── config/ # Configuration classes (Redis, Swagger, Web)
|
||||
└── util/ # Utility classes and JSP functions
|
||||
```
|
||||
|
||||
### Redis Integration
|
||||
|
||||
- **Cluster Configuration**: Multi-node Redis cluster setup via RedissonConfig
|
||||
@@ -55,12 +77,14 @@ mvn clean package
|
||||
### Testing
|
||||
|
||||
```bash
|
||||
# Run all tests
|
||||
# Run all tests (if available)
|
||||
mvn test
|
||||
|
||||
# Run specific test
|
||||
# Run specific test classes
|
||||
mvn test -Dtest=FlashSaleServiceTest
|
||||
mvn test -Dtest=RedisServiceTest
|
||||
|
||||
# Note: Test classes may need to be created for comprehensive testing
|
||||
```
|
||||
|
||||
### Database Setup
|
||||
@@ -109,9 +133,9 @@ mysql -u root -p flash_sale_db < src/main/resources/sql/test-data.sql
|
||||
|
||||
### Testing Approach
|
||||
|
||||
- Unit tests exist for core services (FlashSaleServiceTest, RedisServiceTest)
|
||||
- Integration tests should verify Redis cluster connectivity
|
||||
- Load testing recommended for flash sale scenarios
|
||||
- Unit tests should be created for core services (FlashSaleService, RedisService, CartService)
|
||||
- Integration tests should verify Redis cluster connectivity and database operations
|
||||
- Load testing recommended for flash sale scenarios to validate concurrency handling
|
||||
|
||||
## Lua Script Usage
|
||||
|
||||
@@ -132,4 +156,11 @@ The system includes 5 Lua scripts in `src/main/resources/lua/`:
|
||||
|
||||
- **Actuator Endpoints**: /actuator/health, /actuator/metrics, /actuator/prometheus
|
||||
- **Log Files**: logs/flash-sale-system.log with detailed Redis and SQL logging
|
||||
- **Debug Level**: Enabled for package com.org.flashsalesystem and Redis operations
|
||||
- **Debug Level**: Enabled for package com.org.flashsalesystem and Redis operations
|
||||
|
||||
## Security Considerations
|
||||
|
||||
- **Redis Authentication**: Cluster uses password authentication as configured in application.yml
|
||||
- **Database Connection**: Uses HikariCP with connection pooling and timeout configurations
|
||||
- **Password Encoding**: Spring Security crypto for password hashing
|
||||
- **Rate Limiting**: Built-in rate limiting to prevent abuse of flash sale endpoints
|
||||
Reference in New Issue
Block a user