Files
dc_project/CLAUDE.md
2025-11-12 11:45:35 +08:00

168 lines
4.9 KiB
Markdown

# CLAUDE.md
- 对话过程使用简体中文交流;
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
## Project Overview
This is a **laboratory management system** built with Spring Boot 3.5.7 and Java 17. The application provides functionality for managing laboratories, equipment, personnel, and test records.
## Tech Stack
- **Framework**: Spring Boot 3.5.7
- **Java Version**: 17
- **Build Tool**: Maven
- **Database**: MySQL 8.3.0
- **ORM**: MyBatis-Plus 3.5.14
- **Authentication**: Sa-Token 1.44.0
- **Cache**: Redis
- **Database Pool**: Druid 1.2.23
- **API Docs**: SpringDoc OpenAPI 2.3.0
- **JSON**: FastJSON2 2.0.46
- **Utilities**: Hutool 5.8.24, Lombok 1.18.34
## Architecture
The project follows a standard layered architecture:
```
com.dc.dc_project/
├── config/ # Configuration classes
├── controller/ # REST API endpoints (currently empty)
├── service/ # Business logic
│ └── impl/ # Service implementations
├── mapper/ # MyBatis-Plus data access layer
├── model/ # Data models
│ ├── pojo/ # Entity models (database tables)
│ ├── dto/ # Data Transfer Objects
│ ├── vo/ # View Objects
│ └── Base.java # Base model class
├── enums/ # Enumerations (currently empty)
└── DcProjectApplication.java
```
## Common Commands
### Build and Run
```bash
# Build the project
./mvnw clean compile
# Package the application
./mvnw clean package -DskipTests
# Run the application
./mvnw spring-boot:run
# Run with specific profile
./mvnw spring-boot:run -Dspring-boot.run.profiles=dev
```
### Testing
```bash
# Run all tests
./mvnw test
# Run a single test class
./mvnw test -Dtest=DcProjectApplicationTests
# Run tests with verbose output
./mvnw test -X
```
### Database Operations
```bash
# Run migrations (if using Flyway/Liquibase)
# None configured - migrations are handled manually
# Generate MyBatis-Plus code
# Use the generator package: src/main/resources/generator/
```
## Key Configuration
### Database
- **MySQL Database**: `dc_lab_system`
- **Connection**: Configured in `src/main/resources/application.yml`
- **Mapper Files**: Located in `src/main/resources/mapper/`
- **Pagination**: MySQL dialect with PaginationInnerInterceptor
### Authentication
- **Sa-Token**: Configured in `config/SaTokenConfigure.java`
- **Protected Routes**: `/project/**` paths require authentication
- **Token Name**: `token`
### Redis
- **Host**: 117.72.219.63 (configured in application.yml)
- **Database**: 1
- Used for session management and caching
## Development Patterns
### Data Access Layer
- Mappers extend `BaseMapper<T>` from MyBatis-Plus
- Mapper XML files define resultMap and SQL snippets
- Automatic CRUD operations available through base interface
Example:
```java
public interface UserMapper extends BaseMapper<User> {
// CRUD methods automatically available
}
```
### Service Layer
- Services implement custom interfaces
- ServiceImpl classes extend `ServiceImpl<Mapper, Entity>`
- Example: `EquipmentServiceImpl extends ServiceImpl<EquipmentMapper, Equipment> implements EquipmentService`
### Models
- Entities use MyBatis-Plus annotations (`@TableName`, `@TableId`, `@TableField`)
- Lombok `@Data` annotation generates getters/setters
- Entities include common fields: id, createdAt, updatedAt, isDeleted
### Authentication
- Use `StpUtil.checkLogin()` to verify authentication
- Sa-Token automatically validates tokens from requests
- Manual token management via `StpUtil.login()`, `StpUtil.logout()`
## Domain Entities
The system manages the following core entities:
- **User**: System users with roles and permissions
- **Role**: User roles
- **Permission**: System permissions
- **Org**: Organizations/departments
- **Personnel**: Lab personnel
- **Laboratory**: Laboratory information
- **Equipment**: Equipment inventory
- **Record**: Test records
- **RecordSample**: Samples for testing
- **RecordEntrust**: Entrusted tests
- **RecordResult**: Test results
- **RecordReport**: Test reports
- **Standard**: Testing standards
- **StandardCategory**: Standard categories
- **StandardParam**: Standard parameters
## API Documentation
- **Swagger UI**: Available at `/swagger-ui.html` (when running)
- **OpenAPI JSON**: Available at `/v3/api-docs`
## Current Project Status
- **Database models**: Complete with 20+ entity classes
- **Mapper layer**: Complete with XML files for all entities
- **Service layer**: Interface definitions exist, implementations are minimal
- **Controller layer**: Empty - needs implementation
- **Tests**: Basic Spring Boot test configured
## Notes
- File upload limit: 100MB (configured in application.yml)
- SQL logging enabled with `StdOutImpl` for debugging
- Hutool utilities available for common operations
- FastJSON2 used for JSON serialization