# CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

## Project Overview

Weather data management system -- a multi-module Maven project with a Spring Boot backend and Vue 3 frontend for managing meteorological monitoring data from weather stations.

- **Backend**: Spring Boot 3.5.11, Java 17, Apache Shiro, MyBatis-Plus, Quartz
- **Frontend**: Vue 3 + TypeScript + Vite 5, Element Plus, ECharts, Pinia
- **Database**: MySQL 8.0 (primary), supports Oracle / SQL Server / PostgreSQL / Dameng via dynamic datasource
- **Cache**: Redis (Lettuce client)

## Project Conventions

- **No emoji**: Avoid using emoji in code (including variable names, comments, commit messages) and in response messages. Use plain text instead.
- **Keep CLAUDE.md files current**: Any operation that adds, deletes, or modifies files affecting project structure (new modules, new packages, renamed components, dependency changes, config changes, schema changes, etc.) must update the relevant CLAUDE.md file(s) -- top-level for cross-cutting changes, module-level for module-specific changes.

## Module Index

| Module | Path | Purpose |
|--------|------|---------|
| system-common | `system-common/` | Shared library: base classes, Redis, validation, XSS, utilities |
| system-dynamic-datasource | `system-dynamic-datasource/` | Multi-datasource support via AbstractRoutingDataSource |
| system-admin | `system-admin/` | Main Spring Boot application, REST API, jobs, security |
| weather-data-ui | `weather-data-ui/` | Vue 3 frontend |

Each module has its own `CLAUDE.md` with module-specific architecture and conventions. When working in a module, read that module's CLAUDE.md for context.

## Build & Run Commands

### Database Setup

```bash
mysql -u root -p -e "CREATE DATABASE IF NOT EXISTS weather_data_system DEFAULT CHARSET utf8mb4"
mysql -u root -p weather_data_system < system-admin/db/weather_data_system.sql
mysql -u root -p weather_data_system < system-admin/db/init_system_params.sql
```

### Backend

```bash
# Build everything (skip tests)
mvn clean package -DskipTests

# Build everything with tests
mvn clean package

# Build only system-admin module
cd system-admin && mvn package -DskipTests

# Run a single test class
cd system-admin && mvn test -Dtest=RedisTest -DfailIfNoTests=false

# Run with dev profile (most common for local dev)
cd system-admin && mvn spring-boot:run -Dspring-boot.run.profiles=dev

# Run with other profiles
cd system-admin && mvn spring-boot:run -Dspring-boot.run.profiles=test
cd system-admin && mvn spring-boot:run -Dspring-boot.run.profiles=prod
```

Main entry: `system-admin/src/main/java/com/weather/AdminApplication.java`. Default account: `admin` / `admin`.

Backend is served at `http://localhost:8080/system-admin`. API docs at `http://localhost:8080/system-admin/doc.html`. Druid monitoring at `http://localhost:8080/system-admin/druid/`.

### Frontend

```bash
cd weather-data-ui
npm install
npm run dev          # dev server on port 8001, proxies /system-admin to backend
npm run build        # production build, outputs to dist/
npm run lint         # ESLint on src/**/*.{vue,ts}
npm run serve        # build + vite preview
```

The Vite dev server proxies `/system-admin` requests to the backend. Edit `weather-data-ui/.env.development` and set `VITE_APP_API` to change the backend URL.

## Key Configuration

- **Dev profile** (`application-dev.yml`): local MySQL (weather_data_system), Redis 127.0.0.1:6379
- **Test profile** (`application-test.yml`): test server MySQL (192.168.2.186), Redis 192.168.2.186:6379
- **Prod profile** (`application-prod.yml`): production configuration with external DB/Redis
- **project-options.redis.open**: toggles Redis caching globally (set via sys_params table)
- **Tests are skipped by default**: `maven-surefire-plugin` has `<skipTests>true</skipTests>`. Tests use JUnit 4 with `SpringRunner` (`@SpringBootTest`). Override with `-DskipTests=false` or run individual tests via `-Dtest=`.
- **JDBC URL** uses `rewriteBatchedStatements=true` for MySQL batch INSERT optimization.
