项目优化,构建文件Lombok异常问题修复

This commit is contained in:
2026-06-29 13:55:42 +08:00
parent 53b3b2c989
commit 0799f9cb4d
47 changed files with 1034 additions and 865 deletions
+61 -12
View File
@@ -1,20 +1,69 @@
# CLAUDE.md system-common
# CLAUDE.md - system-common
Shared Java library used by all backend modules.
This file provides guidance to Claude Code when working in the system-common module.
---
## Purpose
## Service layer pattern
Shared library module used by all other backend modules. Provides base classes, utilities, and cross-cutting concerns. This module has no main class and is not runnable on its own.
Two base classes defined here:
## Base Class Hierarchy
| Base | Purpose |
|---|---|
| `CrudService<Dao, Entity, DTO>` | Generic CRUD: `page()`, `get()`, `save()`, `update()`, `delete()` |
| `BaseService<Dao>` | Lighter base without DTO generic |
### BaseEntity (`com.weather.common.entity.BaseEntity`)
These are used by all service implementations in `system-admin` and other modules. See `system-admin/CLAUDE.md` for the full module convention.
All entities must extend this. Provides:
- `id` (Long, `@TableId`)
- `creator` (Long, `@TableField(fill = INSERT)`)
- `createDate` (Date, `@TableField(fill = INSERT)`)
## i18n validation messages
### BaseDao (`com.weather.common.dao.BaseDao<M, T>`)
Located at `src/main/resources/i18n/validation.properties`. Hibernate Validator messages used by `@RestControllerAdvice` exception handler in `system-admin`. Error codes follow `int` scheme: 5 digits, first 2 = module, last 3 = business (e.g. `10001`-`10029`).
Extends MyBatis-Plus `BaseMapper<T>`. Provides `getById(Long id)` as an alias.
### Service Layer
```
BaseService<T> # tag interface
└── CrudService<T, D> # page/list/get/save/update/delete
└── BaseServiceImpl<M, T> # dao injection + insert/updateById wrappers
└── CrudServiceImpl<M, T, D> # generic CRUD with getWrapper()
```
`CrudServiceImpl` is the key base class for all business services. Subclasses only need to implement `getWrapper(Map<String, Object> params)` to define query conditions. Entity-to-DTO conversion uses `ConvertUtils.sourceToTarget()`.
## Redis
- `RedisConfig`: Creates `RedisTemplate<String, Object>` with Jackson JSON serialization
- `RedisUtils`: Wraps `RedisTemplate` operations -- `set/get/delete/deleteByPattern/hGet/hSet/hDelete/expire`
- `RedisKeys`: Static factory for standardized key names (e.g. `getWeatherSummarizeKey()`, `getWeatherSummarizePattern()`)
- `RedisAspect`: AOP aspect that logs Redis operation errors
## Validation
- `ValidatorUtils`: Bean Validation wrapper using Jakarta Validator
- `AssertUtils`: Assertion helpers that throw `CommonException` on failure
- `group/`: Validation groups -- `AddGroup`, `UpdateGroup`, `DefaultGroup`
## XSS Protection
- `XssFilter`: Servlet filter that wraps requests with `XssHttpServletRequestWrapper`
- `XssUtils`: HTML entity encoding using Jsoup
## Exception Handling
- `CommonException`: Application-level runtime exception with error code
- `ExceptionUtils`: Factory methods for creating typed exceptions
- `ErrorCode`: Interface with error code constants
## Utilities
- `ConvertUtils`: Bean copy with recursive conversion support for nested objects
- `DateUtils`: Date parsing/formatting
- `JsonUtils`: JSON serialization via Jackson
- `TreeUtils`: Build tree structures from flat lists (used for menus, depts, regions)
- `HttpContextUtils`: Servlet request/response helpers
- `IpUtils`: Extract client IP from request
- `MessageUtils`: i18n message resolution
- `SpringContextUtils`: Access Spring ApplicationContext statically
- `Result<T>`: Standard API response wrapper with `code`, `msg`, `data`
- `PageData<T>`: Paginated response with `total`, `list`
- `TreeNode`: Tree node interface with `getId/setId/getPid/setPid/getChildren/setChildren`