Skip to content

Commit 06f55a7

Browse files
xlorneclaude
andcommitted
docs: README 改为双版本线简介,文档全面对齐实际代码
- README 仅保留 17.3.x(JDK 17/Spring Boot 3)与 8.2.x(JDK 8/Spring Boot 2)两条版本线简介; 本分支无示例工程,不包含示例运行内容 - 移植与代码对齐后的文档体系:wiki(含新增 script 页)、conventions、capabilities (含 docs/agents 镜像),版本号适配为 8.2.x,servlet 命名空间说明适配 javax - CLAUDE.md 重写:补充模块架构、核心模式、配置项,注明 javax 约束与无示例工程 - CONTRIBUTING 更新 JDK 要求(8)、分支模型与构建指引 Co-Authored-By: Claude <noreply@anthropic.com>
1 parent e95e2df commit 06f55a7

50 files changed

Lines changed: 8769 additions & 152 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CLAUDE.md

Lines changed: 96 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -2,70 +2,122 @@
22

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

5-
## 项目概览
5+
## 项目概述
66

7-
`com.codingapi.springboot:springboot-parent`(当前开发版本 `8.2.0-SNAPSHOT`)是一套基于 Spring Boot 2.7.18 + JDK 8 的**领域驱动设计(DDD)落地框架**,围绕"事件风暴 + 数据权限 + 动态脚本"三大支柱提供可插拔的 starter 模块。框架代码本身即是规范,业务方按需引入 starter 即可获得对应能力,无需重复造轮子
7+
springboot-framework 是一个基于 Spring Boot 2.7.18(Java 8)的多模块企业级开发框架,由 CodingApi 团队维护。核心定位是为领域驱动设计(DDD)与事件风暴提供开箱即用的基础设施。当前开发版本为 `8.2.0-SNAPSHOT`,采用 Maven `${revision}` CI-Friendly 版本机制,正式发布时通过 `-Drevision=x.y.z` 指定正式版本号。版本号含义:8 = 最低 JDK 版本,2 = Spring Boot 大版本,第三位为补丁版本
88

9-
版本采用 CI-Friendly 机制:pom 版本声明为 `${revision}`,开发期锁定 `8.2.0-SNAPSHOT`(版本号含义:8 = JDK 8,2 = Spring Boot 2.x 大版本,第三位为补丁版本),正式发布时通过 `-Drevision=x.y.z` 指定正式版本号,无需修改 pom
9+
**回复语言**:请使用中文进行回答
1010

11-
详细能力文档见 `docs/capabilities/index.md`(共 8 篇),开发规范见 `docs/conventions/index.md`
11+
**版本线说明**:本仓库维护两条版本线——`17.3.x`(JDK 17 / Spring Boot 3.x)与 `8.2.x`(JDK 8 / Spring Boot 2.x,当前分支)。两条版本线功能基本一致,主要差异为 JDK 与 Spring Boot 代际:本分支使用 `javax.*` 命名空间(如 `javax.servlet``javax.persistence`),**禁止使用** `jakarta.*`。本分支不包含示例工程(example)与前端工程(frontend)
1212

13-
## 模块拓扑与依赖
13+
## 常用命令
14+
15+
```bash
16+
# 全量构建
17+
./mvnw clean install
18+
19+
# 仅运行测试(CI 使用)
20+
./mvnw clean test -P travis
21+
22+
# 运行单个模块的测试
23+
./mvnw test -pl springboot-starter
24+
./mvnw test -pl springboot-starter-security
25+
26+
# 运行单个测试类
27+
./mvnw test -pl springboot-starter -Dtest=SomeTestClass
28+
29+
# 正式发布(通过 -Drevision 指定正式版本号,无需修改 pom)
30+
./mvnw clean deploy -P ossrh -Drevision=8.2.0
31+
```
32+
33+
## 模块架构
34+
35+
### Starter 模块(框架核心)
36+
37+
| 模块 | 职责 |
38+
|------|------|
39+
| `springboot-starter` | 核心基础:统一 Response DTO、分页 PageRequest/Filter、事件系统、国际化异常、事务管理 |
40+
| `springboot-starter-security` | Spring Security + JWT 无状态认证 / Redis 有状态认证,加解密支持 |
41+
| `springboot-starter-data-fast` | JPA 增强:FastRepository 支持动态过滤查询、HQL 构建、SearchRequest |
42+
| `springboot-starter-data-authorization` | 数据权限:通过 JDBC Connection/Statement 代理拦截 SQL,透明注入权限条件 |
43+
| `springboot-starter-script` | Groovy 脚本引擎:运行时编译、LRU 缓存、热更新,提供 REST API |
44+
45+
### 自动配置注册
46+
47+
各 starter 模块同时维护 `META-INF/spring.factories`(兼容旧版)和 `META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports`(Spring Boot 2.7+ 支持)。新增 starter 时需同时注册这两种文件。
1448

15-
多模块项目,根 `pom.xml` 中只激活 `springboot-starter-data-authorization`;完整 5 模块通过 `dev` / `travis` / `ossrh` profile 激活。模块依赖**严格单向**,不得反向依赖:
49+
### 模块间依赖关系
1650

1751
```
18-
springboot-starter (基础 DDD 框架:领域事件、代理、异常、加密、HTTP 代理)
19-
20-
├─→ springboot-starter-script (Groovy 脚本引擎,依赖 starter)
21-
│ │
22-
│ └─→ springboot-starter-data-fast (JPA 增强 + 脚本映射,依赖 starter+script)
23-
24-
└─→ springboot-starter-security (JWT/Redis 双模 Token 网关,依赖 starter)
25-
26-
└─→ springboot-starter-data-authorization (行+列数据权限,**仅在根 pom 直接声明**)
52+
springboot-starter (核心,无外部依赖)
53+
├── springboot-starter-security (依赖 starter)
54+
├── springboot-starter-data-fast (依赖 starter)
55+
├── springboot-starter-data-authorization (依赖 starter + JSqlParser)
56+
└── springboot-starter-script (依赖 starter + Groovy)
2757
```
2858

29-
⚠️ `springboot-starter-data-authorization` 不依赖 starter,自带 jsqlparser 解析 SQL,改写后通过 `AuthorizationJdbcDriver` 在结果集层做列权限脱敏
59+
注意:根 `pom.xml` 默认 `<modules>` 中仅包含 `springboot-starter-data-authorization`,完整 5 模块通过 `dev` / `travis` / `ossrh` profile 激活
3060

31-
## 关键架构决策
61+
## 核心架构模式
3262

33-
| 决策 | 体现位置 | 说明 |
34-
|------|---------|------|
35-
| **领域事件总线** | `framework/event/` | 自研 `EventPusher` + `DomainEvent`,支持同步/异步/事务后(`@TransactionalEventListener AFTER_COMMIT`),通过 `EventTraceContext` 检测循环事件 |
36-
| **CGLIB 实体代理** | `framework/domain/proxy/` | `DomainProxyFactory.create()` 在 setter 调用前后对比字段差异,自动发布 `DomainChangeEvent`,无需在业务 setter 中写事件代码 |
37-
| **脚本热加载** | `script/GroovyScript*` | 编译缓存用 SHA-256 做 key;`TempGroovyScript` 临时脚本由 `GroovyScriptEngineRunner` 在启动时从 DB 恢复、应用关闭时落盘 |
38-
| **双模 Token** | `security/gateway/TokenGateway` | 同一接口有 `JwtTokenGateway`(无状态)和 `RedisTokenGateway`(可踢人)两种实现,通过 `codingapi.security.token.type` 切换 |
39-
| **行+列双层权限** | `authorization/` | `DefaultSQLInterceptor` 在 SQL 执行前用 `JSqlParser` 递归改写 WHERE;`ResultSetProxy` 在结果集读取时通过 `ColumnHandlerContext` 脱敏 |
40-
| **泛型签名一致性** | `framework/utils/RandomGenerator`| JDK 8 编译时必须显式声明 `LinkedHashMap<String,Script>` 等类型,依赖 IDE 推断会丢失泛型信息(见 git log 中 `GroovyScriptRuntime` 修复记录) |
41-
| **javax.persistence 适配** | 所有 `*Repository` 接口 | 项目基于 Spring Boot 2.7.18,对应 JPA 2.x;**禁止使用** `jakarta.persistence.*`(那是 Spring Boot 3.x / Jakarta EE 9+) |
63+
### 事件系统(Event System)
4264

43-
## 常用命令
65+
框架自建的发布-订阅事件机制,是 DDD 领域事件的核心基础设施:
4466

45-
```bash
46-
# 构建
47-
./mvnw clean install -DskipTests # 跳过测试
48-
./mvnw clean test # 全量测试(默认 dev profile)
67+
- **`IEvent`** — 事件标记接口,分为 `ISyncEvent`(同步)和 `IAsyncEvent`(异步)
68+
- **`IHandler<T extends IEvent>`** — 事件处理器,支持 `order()` 排序和 `error()` 异常回调
69+
- **`EventPusher.push(event, sync)`** — 事件推送入口
70+
- **`DomainEvent`** — 领域实体事件基类,派生 `DomainCreateEvent``DomainChangeEvent``DomainDeleteEvent`
71+
- **`DomainChangeInterceptor`** — 通过代理拦截实体字段变更,自动推送 `DomainChangeEvent`
4972

50-
# 单模块测试
51-
./mvnw -pl springboot-starter -am test
52-
./mvnw -pl springboot-starter-script -Dtest=GroovyScriptRuntimeContextTest test
73+
标注 `@Handler`(或 `@Component`/`@Service`)的处理器会被注册为 Spring Bean;`SpringHandlerConfiguration` 收集容器中所有 `IHandler` Bean,在构造事件处理器时通过 `addHandlers` 统一注册到 `ApplicationHandlerUtils`
5374

54-
# 部署 profile
55-
./mvnw clean test -P travis # 启用 jacoco + clover
75+
### 统一响应封装
5676

57-
# 正式发布(通过 -Drevision 指定正式版本号,无需修改 pom)
58-
./mvnw clean deploy -P ossrh -Drevision=8.2.0 # 推送到 Sonatype(需 GPG)
77+
```java
78+
Response // 基础响应(success / errCode / errMessage)
79+
SingleResponse<T> // 单对象响应
80+
MultiResponse<T> // 列表响应
81+
MapResponse // Map 响应
82+
```
83+
84+
### 数据查询(PageRequest + FastRepository)
85+
86+
`PageRequest` 扩展了 Spring Data 的 `PageRequest`,增加了 `RequestFilter` 动态过滤条件:
87+
88+
```java
89+
PageRequest request = PageRequest.of(0, 20);
90+
request.addFilter("name", "张三");
91+
request.addFilter("age", Relation.GREATER_THAN, 18);
92+
Page<User> page = userRepository.findAll(request);
5993
```
6094

61-
测试基于 H2 内存库(`com.h2database:h2` scope=test),无需外部 DB(H2 关闭时的告警是正常的)。
95+
`FastRepository.findAll(PageRequest)` 全部为等值条件时构建 Example 查询;包含 LIKE/范围/IN/OR 等复杂条件时自动切换 `DynamicSQLBuilder` 构建的 HQL 查询。
96+
97+
### 数据权限(SQL 拦截)
98+
99+
`ConnectionProxy``PreparedStatementProxy` / `StatementProxy` 代理链,在 SQL 执行前通过 `SQLRunningContext.intercept(sql)` 注入权限条件,实现透明的行级数据过滤。使用 JSqlParser 解析和改写 SQL。列级脱敏通过 `ResultSetProxy` + `ColumnHandlerContext` 在结果集读取时完成。
100+
101+
## 框架配置项
102+
103+
`application.properties` 中可用的配置前缀:
104+
105+
```properties
106+
# 安全模块
107+
codingapi.security.jwt.enable=true # 启用 JWT 认证(必须显式开启)
108+
codingapi.security.redis.enable=true # 启用 Redis 有状态认证(必须显式开启)
109+
codingapi.security.ignore-urls=/open/**,/#/** # 免认证 URL 列表
110+
111+
# 框架核心
112+
codingapi.framework.handler-thread-pool-size=20 # 事件异步线程池大小
113+
114+
# 数据权限
115+
codingapi.data-authorization.show-sql=false # 打印拦截后的 SQL
116+
```
62117

63-
## 文档与知识库
118+
## 关键依赖版本
64119

65-
- `README.md` — 模块列表、maven 依赖、版本说明
66-
- `docs/capabilities/` — 8 篇核心能力文档(DDD 事件、领域代理、Groovy 脚本、JDBC 代理、SQL 拦截器、JPA 仓储、Token 网关、Spring Boot 基础)
67-
- `docs/conventions/` — 项目开发规范(待补全)
68-
- Wiki:https://github.com/codingapi/springboot-framework/wiki
120+
见根 `pom.xml``<properties>` 区块。主要版本:Groovy 4.0.24、JSqlParser 5.0、Fastjson 2.0.53、JJWT 0.12.6、H2 1.4.200。
69121

70122
<!-- PKR-START -->
71123
## PKR 知识查阅(编码前必须)

CONTRIBUTING.md

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,17 @@ Please make sure to read and observe our [Code of Conduct](./CODE_OF_CONDUCT.md)
1111

1212
### Setting up your development environment
1313

14-
You should have JDK 1.8 or later installed in your system.
14+
You should have JDK 8 or later installed in your system.
15+
16+
The project ships with the Maven Wrapper, so there is no need to install Maven separately.
17+
18+
```bash
19+
# Full build
20+
./mvnw clean install
21+
22+
# Run the tests only (the same command CI uses)
23+
./mvnw clean test -P travis
24+
```
1525

1626
## Contributing
1727

@@ -23,7 +33,13 @@ We are very glad to accept improvements for these aspects.
2333

2434
### GitHub workflow
2535

26-
We use the `dev` branch as the development branch, which indicates that this is a unstable branch.
36+
Development mainly happens on version branches (e.g. `8.2.x`, `17.3.x`) and on the `dev` branch,
37+
which is an unstable branch. The `main` branch stays stable, and CI runs on pushes and pull requests
38+
targeting `main`, `dev`, `2.x` and `8.2.x`.
39+
40+
The project version (e.g. `8.2.0-SNAPSHOT`, where `8` is the minimum JDK version, `2` is the Spring Boot
41+
major version and the last number is the patch version) is managed with the Maven `${revision}`
42+
CI-Friendly mechanism, so no `pom.xml` needs to be modified during development or for a release.
2743

2844
Here are the workflow for contributors:
2945

@@ -74,4 +90,4 @@ All code should be well reviewed by one or more committers. Some principles:
7490

7591
#### Mailing list
7692

77-
If you have any questions or advice, please contact 1991wangliang@gmail.com.
93+
If you have any questions or advice, please contact wangliang@codingapi.com.

0 commit comments

Comments
 (0)