# CLAUDE.md This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. ## Project Overview A Spring Boot integration server ("dataserver") that bridges YunShu (云枢/cloudpivot, a low-code platform) with U8 ERP (Yonyou). It synchronizes business documents — sales orders, purchase orders, inventory, deliveries, returns, payments — between the two systems via direct SQL Server database operations and REST APIs. ## Build & Run ```bash mvn clean package # Build JAR (tests skipped by default) mvn spring-boot:run # Run locally (port 9901) java -jar target/dataserver-0.0.1-SNAPSHOT.jar # Run packaged JAR mvn test # Run tests (skipped by default in surefire plugin) ``` Java 8 required. No linter or code quality tools are configured. ## Architecture ### Multi-Datasource Setup Three datasources configured via separate `@Configuration` classes with `@MapperScan`: | Datasource | Config Class | Mapper Package | XML Mappers | Purpose | |---|---|---|---|---| | SQL Server (primary) | `ConfigDbSqlsever` | `mapper/` | `resources/mapper/` | U8 ERP database (`UFDATA_xxx_xxxx`) | | MySQL | `ConfigDbYunshu` | `mapperYunShu/` | `resources/mapperYunShu/` | YunShu/cloudpivot platform database | | SQL Server (UFSystem) | `ConfigUFSystemSqlsever` | `mapperUFSystem/` | `resources/mapperUFSystem/` | U8 system database (user identity) | Each datasource has its own `SqlSessionFactory`, `DataSource`, and `TransactionManager`. When adding new mappers, place them in the correct package and XML directory for the target datasource. ### Layered Structure `controller/` → `service/` (interface) → `service/impl/` → `mapper/` (MyBatis interface) → XML mapper SQL Base package: `com.youwei.dataserver` ### Authentication - Shiro + JWT (`JWTFilter` intercepts all requests) - Additional token validation via `TokenFilter` and `YsTokenFilter` - SSO support via CAS client ### Integration Pattern YunShu workflow forms → REST calls to this server → reads/writes U8 SQL Server + YunShu MySQL to sync business data. ## Environment Profiles Set active profile in `application.yml` (`spring.profiles.active`). Available: `dev`, `test`, `pre`, `prod`, `prod2`. Each profile configures database connections, Redis, and environment-specific settings. ## Key Areas - **`controller/SaleController.java`** — Main business logic: sales orders, purchase orders, inventory, deliveries, payments - **`controller/BasicDataController.java`** — Master data sync (customers, suppliers, inventory items) - **`entity/U8/`** — DTOs mapping to U8 SQL Server tables - **`config/`** — All Spring configuration including datasources, Redis, Shiro, WebSocket, and HTTP filters - **`common/ResultCommon.java`** — Standard API response wrapper ## Conventions - All API responses use `ResultCommon` wrapper - MyBatis XML mappers contain the actual SQL — mapper interfaces define the method signatures only - Entity classes use Lombok (`@Data`, `@Builder`, etc.) - JSON handling uses Alibaba Fastjson throughout - Excel import/export uses Alibaba EasyExcel